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 985283858284 for ; Tue, 30 Aug 2022 10:41:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 985283858284 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D943E222A4; Tue, 30 Aug 2022 10:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661856093; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hw3JgZIw95SNVUcR3RpN3SASWi7PTIlV5pnwIxtpCIA=; b=vOyGk6aZmxy0Gl5ck0nYhOZBCMmNggi3f2IIIQWinuTfjxBDi2JMll20beAHK61avG5IB3 +GLmQ3+yHv7E5G9+6g6m+D1zZm2CjngAFT3NAfW6GZOefZqeY0MmUj+/dFOplxumHrwD+g x0sJ9qGewm7hRRt5P3GZ/uptv0QHGGE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661856093; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hw3JgZIw95SNVUcR3RpN3SASWi7PTIlV5pnwIxtpCIA=; b=j0Rv6OEeJ9IU8lYl3/waqACasyWCHWQqdCo3EUoT5NM6KgcQqe2/xdwnBrRlVQfiRGegx8 WIU7IJIwi5yG0SDQ== 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 CFD2B2C141; Tue, 30 Aug 2022 10:41:33 +0000 (UTC) Date: Tue, 30 Aug 2022 10:41:33 +0000 (UTC) From: Richard Biener To: Richard Sandiford cc: Richard Biener via Gcc-patches , Tamar Christina , nd@arm.com Subject: Re: [PATCH][committed]middle-end intialize regnum in store_bit_field_1 In-Reply-To: Message-ID: References: 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=-10.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 30 Aug 2022, Richard Sandiford wrote: > Richard Biener via Gcc-patches writes: > > On Tue, 30 Aug 2022, Tamar Christina wrote: > > > >> Hi All, > >> > >> This initializes regnum to 0 for when undefined_p. > >> 0 is the right default as it's supposed to get the lowpart > >> when undefined. > >> > >> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > >> > >> Ok for master? > > > > OK. > > I'm not sure this is the right fix. We were still supposed to use the > correct byte offset in the undefined case. > > Is the attached OK? Tested on aarch64-linux-gnu. OK. Thanks, Richard. > Thanks, > Richard > > ---------------------- > > store_bit_field_1 tries to convert a field assignment into a subreg > assignment. Normally it must check that the field occupies a full > word (or more specifically, a full REGMODE_NATURAL_SIZE chunk), > so that writing to the subreg doesn't clobber any other fields. > But it can skip that check if the structure is known to be in > an undefined state. > > The idea was that, in the undefined case, we could rely on > simplify_gen_subreg to do the check for a valid subreg, rather > than having to repeat the required endianness logic in the caller. > > Before the addition of the undefined case, the code could use > regnum * regsize to get the byte offset, where regnum came from > checking that the start was word-aligned. In the undefined case > we need to calculate the byte offset explicitly. > > gcc/ > * expmed.cc (store_bit_field_1): Fix byte offset calculation > for undefined structures. > --- > gcc/expmed.cc | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/gcc/expmed.cc b/gcc/expmed.cc > index 8d7418be418..6c02c3bb850 100644 > --- a/gcc/expmed.cc > +++ b/gcc/expmed.cc > @@ -794,7 +794,7 @@ store_bit_field_1 (rtx str_rtx, poly_uint64 bitsize, poly_uint64 bitnum, > words or to cope with mode punning between equal-sized modes. > In the latter case, use subreg on the rhs side, not lhs. */ > rtx sub; > - HOST_WIDE_INT regnum; > + poly_uint64 bytenum; > poly_uint64 regsize = REGMODE_NATURAL_SIZE (GET_MODE (op0)); > if (known_eq (bitnum, 0U) > && known_eq (bitsize, GET_MODE_BITSIZE (GET_MODE (op0)))) > @@ -808,13 +808,13 @@ store_bit_field_1 (rtx str_rtx, poly_uint64 bitsize, poly_uint64 bitnum, > return true; > } > } > - else if (((constant_multiple_p (bitnum, regsize * BITS_PER_UNIT, ®num) > - && multiple_p (bitsize, regsize * BITS_PER_UNIT)) > - || undefined_p) > + else if (multiple_p (bitnum, BITS_PER_UNIT, &bytenum) > + && (undefined_p > + || (multiple_p (bitnum, regsize * BITS_PER_UNIT) > + && multiple_p (bitsize, regsize * BITS_PER_UNIT))) > && known_ge (GET_MODE_BITSIZE (GET_MODE (op0)), bitsize)) > { > - sub = simplify_gen_subreg (fieldmode, op0, GET_MODE (op0), > - regnum * regsize); > + sub = simplify_gen_subreg (fieldmode, op0, GET_MODE (op0), bytenum); > if (sub) > { > if (reverse) > -- 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)