Message ID | 20211008112904.3459907-1-stefansf@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.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 B16FB3857C7B for <patchwork@sourceware.org>; Fri, 8 Oct 2021 11:31:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B16FB3857C7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633692706; bh=lB2kkzdnkMX4nhL/xG713byFxjFG6Z1Ivmku2DfwGZI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Wj0EkLZlAdRYBbIpEXqs7Sk1pQQk+ug1Lx6K3EttWVPDI1VuKImsua+A6p7ZYZFiO ku8QtXGIhZZ7X0HPrF/acWgSwRDNNsPnez0q9SFi6gNrYvB2ugvLLPv6sJTF/Jx3mX kJM3S9att/LDik8jOPd2CTM2zbiUJ3Qt4yALBlkM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B5F803858024 for <gcc-patches@gcc.gnu.org>; Fri, 8 Oct 2021 11:31:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B5F803858024 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 198B1hF6015287 for <gcc-patches@gcc.gnu.org>; Fri, 8 Oct 2021 07:31:17 -0400 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bjgsyx856-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Fri, 08 Oct 2021 07:31:17 -0400 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 198BI5KI003420 for <gcc-patches@gcc.gnu.org>; Fri, 8 Oct 2021 11:31:15 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma01fra.de.ibm.com with ESMTP id 3bef2anxvy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for <gcc-patches@gcc.gnu.org>; Fri, 08 Oct 2021 11:31:15 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 198BPmAk51053038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Oct 2021 11:25:48 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A10AA11C050; Fri, 8 Oct 2021 11:31:08 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C7B811C071; Fri, 8 Oct 2021 11:31:08 +0000 (GMT) Received: from t8345026.lnxne.boe (unknown [9.152.108.100]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 8 Oct 2021 11:31:08 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] regcprop: Determine subreg offset depending on endianness [PR101260] Date: Fri, 8 Oct 2021 13:29:05 +0200 Message-Id: <20211008112904.3459907-1-stefansf@linux.ibm.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7cTC2fQEUZgm6yA3zYwFTr7wWaBkvbsC X-Proofpoint-ORIG-GUID: 7cTC2fQEUZgm6yA3zYwFTr7wWaBkvbsC 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-08_03,2021-10-07_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 impostorscore=0 phishscore=0 adultscore=0 priorityscore=1501 suspectscore=0 mlxscore=0 bulkscore=0 clxscore=1015 mlxlogscore=723 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110080068 X-Spam-Status: No, score=-8.5 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Stefan Schulze Frielinghaus via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
regcprop: Determine subreg offset depending on endianness [PR101260]
|
|
Commit Message
Stefan Schulze Frielinghaus
Oct. 8, 2021, 11:29 a.m. UTC
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}? --- gcc/regcprop.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Comments
On Fri, Oct 8, 2021 at 1:31 PM Stefan Schulze Frielinghaus via Gcc-patches <gcc-patches@gcc.gnu.org> 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? > --- > 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 >
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 <gcc-patches@gcc.gnu.org> 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 > > From 299959788321e21c27f0d4a6d437a586c5f6c92e Mon Sep 17 00:00:00 2001 From: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com> 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; +}
ping On Mon, Oct 11, 2021 at 02:14:53PM +0200, Stefan Schulze Frielinghaus wrote: > 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 <gcc-patches@gcc.gnu.org> 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 > > > > From 299959788321e21c27f0d4a6d437a586c5f6c92e Mon Sep 17 00:00:00 2001 > From: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com> > 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 >
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);