From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 7D1963857413 for ; Wed, 27 Jul 2022 06:46:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D1963857413 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0A64F3718A; Wed, 27 Jul 2022 06:46:55 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 525462C141; Wed, 27 Jul 2022 06:46:53 +0000 (UTC) Date: Wed, 27 Jul 2022 06:46:53 +0000 (UTC) From: Richard Biener To: zhongjuzhe cc: gcc-patches@gcc.gnu.org, richard.earnshaw@arm.com, jakub@redhat.com, kenner@nyu.edu, jlaw@tachyum.com, gnu@the-meissners.org, jason@redhat.com, davem@redhat.com, joseph@codesourcery.com, richard.sandiford@arm.com, bernds_cb1@t-online.de, ian@airs.com, wilson@tuliptree.org Subject: Re: [PATCH 1/1] Fix bit-position comparison In-Reply-To: <20220727034437.154625-2-juzhe.zhong@rivai.ai> Message-ID: References: <20220727034437.154625-1-juzhe.zhong@rivai.ai> <20220727034437.154625-2-juzhe.zhong@rivai.ai> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2022 06:46:57 -0000 On Wed, 27 Jul 2022, juzhe.zhong@rivai.ai wrote: > From: zhongjuzhe > > gcc/ChangeLog: > > * expr.cc (expand_assignment): Change GET_MODE_PRECISION to GET_MODE_BITSIZE > > --- > gcc/expr.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gcc/expr.cc b/gcc/expr.cc > index 80bb1b8a4c5..ac2b3c07df6 100644 > --- a/gcc/expr.cc > +++ b/gcc/expr.cc > @@ -5574,7 +5574,7 @@ expand_assignment (tree to, tree from, bool nontemporal) > code contains an out-of-bounds access to a small array. */ > if (!MEM_P (to_rtx) > && GET_MODE (to_rtx) != BLKmode > - && known_ge (bitpos, GET_MODE_PRECISION (GET_MODE (to_rtx)))) > + && known_ge (bitpos, GET_MODE_BITSIZE (GET_MODE (to_rtx)))) I think this has the chance to go wrong with regard to endianess. Consider to_rtx with 32bit mode size but 12bit mode precision. bitpos is relative to the start of to_rtx as if it were in memory and bitsize determines the contiguous region affected. But since we are actually storing into a non-memory endianess comes into play. So no, I don't think the patch is correct, it would be way more complicated to get the desired improvement. Richard. > { > expand_normal (from); > result = NULL; > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)