From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 0D1253858D28 for ; Mon, 11 Oct 2021 12:15:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D1253858D28 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19BCBdpK000943 for ; Mon, 11 Oct 2021 08:14:59 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bmn28r27s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Oct 2021 08:14:58 -0400 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19BCEwho013060 for ; Mon, 11 Oct 2021 08:14:58 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bmn28r276-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 08:14:58 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19BC7Id2024042; Mon, 11 Oct 2021 12:14:56 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3bk2q95hc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 12:14:56 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19BCEru846530998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Oct 2021 12:14:54 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D06E711C050; Mon, 11 Oct 2021 12:14:53 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B31211C04C; Mon, 11 Oct 2021 12:14:53 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.185.45]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 11 Oct 2021 12:14:53 +0000 (GMT) Date: Mon, 11 Oct 2021 14:14:52 +0200 From: Stefan Schulze Frielinghaus To: Richard Biener Cc: GCC Patches Subject: Re: [PATCH] regcprop: Determine subreg offset depending on endianness [PR101260] Message-ID: References: <20211008112904.3459907-1-stefansf@linux.ibm.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="UXi1RxUUxvSsUn4V" Content-Disposition: inline In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: M2-URmhQfRUDZGiYW0oLuMhOkTo9CVSQ X-Proofpoint-GUID: hL8R0P7YAEI84i4q-r8eSAHOPc5Rrct8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-11_04,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 mlxscore=0 clxscore=1015 spamscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110110069 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Mon, 11 Oct 2021 12:15:01 -0000 --UXi1RxUUxvSsUn4V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Oct 11, 2021 at 09:38:36AM +0200, Richard Biener wrote: > On Fri, Oct 8, 2021 at 1:31 PM Stefan Schulze Frielinghaus via > Gcc-patches wrote: > > > > gcc/ChangeLog: > > > > * regcprop.c (maybe_mode_change): Determine offset relative to > > high or low part depending on endianness. > > > > Bootstrapped and regtested on IBM Z. Ok for mainline and gcc-{11,10,9}? > > Is there a testcase to add? I've updated the patch and added the testcase from the PR. > > > --- > > gcc/regcprop.c | 11 ++++++++--- > > 1 file changed, 8 insertions(+), 3 deletions(-) > > > > diff --git a/gcc/regcprop.c b/gcc/regcprop.c > > index d2a01130fe1..0e1ac12458a 100644 > > --- a/gcc/regcprop.c > > +++ b/gcc/regcprop.c > > @@ -414,9 +414,14 @@ maybe_mode_change (machine_mode orig_mode, machine_mode copy_mode, > > copy_nregs, &bytes_per_reg)) > > return NULL_RTX; > > poly_uint64 copy_offset = bytes_per_reg * (copy_nregs - use_nregs); > > - poly_uint64 offset > > - = subreg_size_lowpart_offset (GET_MODE_SIZE (new_mode) + copy_offset, > > - GET_MODE_SIZE (orig_mode)); > > + poly_uint64 offset = > > +#if WORDS_BIG_ENDIAN > > + subreg_size_highpart_offset > > +#else > > + subreg_size_lowpart_offset > > +#endif > > + (GET_MODE_SIZE (new_mode) + copy_offset, > > + GET_MODE_SIZE (orig_mode)); > > regno += subreg_regno_offset (regno, orig_mode, offset, new_mode); > > if (targetm.hard_regno_mode_ok (regno, new_mode)) > > return gen_raw_REG (new_mode, regno); > > -- > > 2.31.1 > > --UXi1RxUUxvSsUn4V Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-regcprop-Determine-subreg-offset-depending-on-endian.patch" >From 299959788321e21c27f0d4a6d437a586c5f6c92e Mon Sep 17 00:00:00 2001 From: Stefan Schulze Frielinghaus Date: Mon, 4 Oct 2021 09:36:21 +0200 Subject: [PATCH] regcprop: Determine subreg offset depending on endianness [PR101260] gcc/ChangeLog: * regcprop.c (maybe_mode_change): Determine offset relative to high or low part depending on endianness. gcc/testsuite/ChangeLog: * gcc.dg/pr101260.c: New test. --- gcc/regcprop.c | 11 ++++++-- gcc/testsuite/gcc.dg/pr101260.c | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr101260.c diff --git a/gcc/regcprop.c b/gcc/regcprop.c index d2a01130fe1..0e1ac12458a 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -414,9 +414,14 @@ maybe_mode_change (machine_mode orig_mode, machine_mode copy_mode, copy_nregs, &bytes_per_reg)) return NULL_RTX; poly_uint64 copy_offset = bytes_per_reg * (copy_nregs - use_nregs); - poly_uint64 offset - = subreg_size_lowpart_offset (GET_MODE_SIZE (new_mode) + copy_offset, - GET_MODE_SIZE (orig_mode)); + poly_uint64 offset = +#if WORDS_BIG_ENDIAN + subreg_size_highpart_offset +#else + subreg_size_lowpart_offset +#endif + (GET_MODE_SIZE (new_mode) + copy_offset, + GET_MODE_SIZE (orig_mode)); regno += subreg_regno_offset (regno, orig_mode, offset, new_mode); if (targetm.hard_regno_mode_ok (regno, new_mode)) return gen_raw_REG (new_mode, regno); diff --git a/gcc/testsuite/gcc.dg/pr101260.c b/gcc/testsuite/gcc.dg/pr101260.c new file mode 100644 index 00000000000..0e9ec4e203a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr101260.c @@ -0,0 +1,49 @@ +/* PR rtl-optimization/101260 */ +/* { dg-do run } */ +/* { dg-options -O1 } */ +struct a { + unsigned b : 7; + int c; + int d; + short e; +} p, *q = &p; +int f, g, h, i, r, s; +static short j[8][1][6] = {0}; +char k[7]; +short l, m; +int *n; +int **o = &n; +void t() { + for (; f;) + ; +} +static struct a u(int x) { + struct a a = {4, 8, 5, 4}; + for (; i <= 6; i++) { + struct a v = {0}; + for (; l; l++) + h = 0; + for (; h >= 0; h--) { + struct a *w; + j[i]; + w = &p; + s = 0; + for (; s < 3; s++) { + r ^= x; + m = j[i][g][h] == (k[g] = g); + *w = v; + } + r = 2; + for (; r; r--) + *o = &r; + } + } + t(); + return a; +} +int main() { + *q = u(636); + if (p.b != 4) + __builtin_abort (); + return 0; +} -- 2.31.1 --UXi1RxUUxvSsUn4V--