Message ID | bad971a3bda505005d02a880cd1b6c9eca87d47e.1666192979.git.aburgess@redhat.com |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61AD93851153 for <patchwork@sourceware.org>; Wed, 19 Oct 2022 15:27:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61AD93851153 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666193261; bh=aa8/YU7VD9BQDdmy6R5Vr5h3X9SPyflEAYbnSsDh0ZA=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xsblqD7gOVF6O8ZS6Ufi0VVQbFjI3PL7OPBquAjoCniNjS/zlgFnAhimxoYwuDsik E1vHnB9LYwOXVFmm+oIo4L4GKIETJ4GGzBUwxtrxSDd/S2dyYuPkS4Ttbm40lLBS47 XGQzpbj9WyomQfVS3nIpWR7SgXyMkcNusD4VH6bs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1D5CE3852770 for <gdb-patches@sourceware.org>; Wed, 19 Oct 2022 15:25:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D5CE3852770 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-153-6QGd2Jj6OF6QRrhJ7tLr7g-1; Wed, 19 Oct 2022 11:25:05 -0400 X-MC-Unique: 6QGd2Jj6OF6QRrhJ7tLr7g-1 Received: by mail-qt1-f197.google.com with SMTP id cr15-20020a05622a428f00b0039cf1f8c94fso4606700qtb.5 for <gdb-patches@sourceware.org>; Wed, 19 Oct 2022 08:25:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aa8/YU7VD9BQDdmy6R5Vr5h3X9SPyflEAYbnSsDh0ZA=; b=1hzc2cIsv2roZi4pNtdB5yZSAq762vhZijh+zOB8l+5didbSvNvhuhB8fS83aze5K1 eps0QYXABwdF8C1fXTwKw/DQASpy5iWwbjmifFAl83p4Lkq1omGs6upCIsCmSkFDf9g3 XTk+jr/vdTQejhAE1R4GCIzBnEePjnEA08sxZzxgoYApod8HYMzFx+2fs4rMU0v4yxHT fRKsy99FDZv4E7vg0hcKk9niXkGAHmbvHbb9CZzeqg3DUYoC6lSBh0p4lNcwHLCoELzR U6bDns3uURYT27qqV+X2yzSlsaeJlufbpUV5yhCF2vXnzC3o3D0jzmKCsXRjDl6V6/Rp GBBg== X-Gm-Message-State: ACrzQf2z8A3wEY4kGmZIM7zJuQDPFjENw8q311eIncHzUvXDgQx66Bqu gLRs6Q85w+BvgMt46geHEyEeIsOF+LN9Rq4+U5GR0ayIzIzTDK9mdzM7y61+U2Cx+JBkGpRVvBv YYrkCuKdQyA+k2qVHwfeoH3RtiAa/Y4kqGptyPJQSuGJ17ZMUyyr0ciSoILCcSmMHPtpV7WMk/Q == X-Received: by 2002:a05:620a:4547:b0:6ee:dc16:d67a with SMTP id u7-20020a05620a454700b006eedc16d67amr5997915qkp.23.1666193105003; Wed, 19 Oct 2022 08:25:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4K0Uw4w/DW1P9mJKbyyRazXOPrUmn1Z3RxKgorSpu/yQ86zbZLTouK2/6WEOr6p92BEVteyg== X-Received: by 2002:a05:620a:4547:b0:6ee:dc16:d67a with SMTP id u7-20020a05620a454700b006eedc16d67amr5997884qkp.23.1666193104557; Wed, 19 Oct 2022 08:25:04 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id fe5-20020a05622a4d4500b00342f8984348sm4194854qtb.87.2022.10.19.08.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 08:25:04 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 05/10] sim/ppc: fix for operator precedence warning from clang Date: Wed, 19 Oct 2022 16:24:44 +0100 Message-Id: <bad971a3bda505005d02a880cd1b6c9eca87d47e.1666192979.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <cover.1666192979.git.aburgess@redhat.com> References: <cover.1666192979.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Andrew Burgess <aburgess@redhat.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Building the sim/ tree with clang
|
|
Commit Message
Andrew Burgess
Oct. 19, 2022, 3:24 p.m. UTC
In the ppc simulator, clang was warning about some code like this: busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2; The warning was: operator '?:' has lower precedence than '+'; '+' will be evaluated first I suspect that this is not the original authors intention. PPC_ONE_BIT_SET_P is going to be 0 or 1, so if we evaluate the '+' first, the condition will always be non-zero, so true. The whole expression could then be simplified to just '1', which doesn't make much sense. I suspect the answer the author was expecting was either 2 or 3. Why they didn't just write: busy_ptr->nr_writebacks = (PPC_ONE_BIT_SET_P(out_vmask)) ? 2 : 3; I have no clue, however, to keep the structure of the code unchanged, I've updated things to: busy_ptr->nr_writebacks = 1 + ((PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2); which silences the warning from clang, and is, I am guessing, what the original author intended. --- sim/ppc/altivec.igen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 19 Oct 2022 16:24, Andrew Burgess via Gdb-patches wrote: > --- a/sim/ppc/altivec.igen > +++ b/sim/ppc/altivec.igen > @@ -231,7 +231,7 @@ void::model-function::ppc_insn_vr_vscr:itable_index index, model_data *model_ptr > busy_ptr->vscr_busy = 1; > > if (out_vmask) > - busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2; > + busy_ptr->nr_writebacks = 1 + ((PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2); should drop the paren around PPC_ONE_BIT_SET_P while you're here otherwise lgtm -mike
Mike Frysinger <vapier@gentoo.org> writes: > On 19 Oct 2022 16:24, Andrew Burgess via Gdb-patches wrote: >> --- a/sim/ppc/altivec.igen >> +++ b/sim/ppc/altivec.igen >> @@ -231,7 +231,7 @@ void::model-function::ppc_insn_vr_vscr:itable_index index, model_data *model_ptr >> busy_ptr->vscr_busy = 1; >> >> if (out_vmask) >> - busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2; >> + busy_ptr->nr_writebacks = 1 + ((PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2); > > should drop the paren around PPC_ONE_BIT_SET_P while you're here Pushed with the fix you suggest. Thanks, Andrew
diff --git a/sim/ppc/altivec.igen b/sim/ppc/altivec.igen index 63fe95a53d5..e7962027bd6 100644 --- a/sim/ppc/altivec.igen +++ b/sim/ppc/altivec.igen @@ -231,7 +231,7 @@ void::model-function::ppc_insn_vr_vscr:itable_index index, model_data *model_ptr busy_ptr->vscr_busy = 1; if (out_vmask) - busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2; + busy_ptr->nr_writebacks = 1 + ((PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2); if (WITH_TRACE && ppc_trace[trace_model]) model_trace_altivec_make_busy(model_ptr, vr_mask, 0);