From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 ; 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 ; 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) From: Andrew Burgess 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: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Oct 2022 15:25:23 -0000 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(-) 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); -- 2.25.4