diff mbox

[rs6000] Fix PR79907

Message ID f4671652-2587-bef0-da4a-7eba2e77a444@linux.vnet.ibm.com
State New
Headers show

Commit Message

Pat Haugen March 8, 2017, 10:29 p.m. UTC
The following patch fixes an "insn does not match its constraints" ICE
that occurred when copying a VR reg to a GPR when -mno-upper-regs-df is
in effect. The regclass used for the wi/wj constraints was being
incorrectly based on TARGET_UPPER_REGS_DF instead of
TARGET_UPPER_REGS_DI. This patch fixes the initialization of the wi
constraint, which in turn is used to set the value of the wj constraint.

Bootstrap/regtest on powerp64le and powerpc64 (-m32/-m64) with no new
regressions. Ok for trunk?

-Pat


2017-03-08  Pat Haugen  <pthaugen@us.ibm.com>

	PR target/79907
	* config/rs6000/rs6000.c (rs6000_init_hard_regno_mode_ok): Test
	TARGET_UPPER_REGS_DI when setting 'wi' constraint regclass.

testsuite/ChangeLog:
2017-03-08  Pat Haugen  <pthaugen@us.ibm.com>

	* gcc.target/powerpc/pr79907.c: New.



+}

Comments

Segher Boessenkool March 9, 2017, 10:26 p.m. UTC | #1
On Wed, Mar 08, 2017 at 04:29:59PM -0600, Pat Haugen wrote:
> The following patch fixes an "insn does not match its constraints" ICE
> that occurred when copying a VR reg to a GPR when -mno-upper-regs-df is
> in effect. The regclass used for the wi/wj constraints was being
> incorrectly based on TARGET_UPPER_REGS_DF instead of
> TARGET_UPPER_REGS_DI. This patch fixes the initialization of the wi
> constraint, which in turn is used to set the value of the wj constraint.
> 
> Bootstrap/regtest on powerp64le and powerpc64 (-m32/-m64) with no new
> regressions. Ok for trunk?

That looks correct.  Okay for trunk, thanks!  Does it need backporting
as well?


Segher


> 2017-03-08  Pat Haugen  <pthaugen@us.ibm.com>
> 
> 	PR target/79907
> 	* config/rs6000/rs6000.c (rs6000_init_hard_regno_mode_ok): Test
> 	TARGET_UPPER_REGS_DI when setting 'wi' constraint regclass.
Pat Haugen March 10, 2017, 2:16 p.m. UTC | #2
On 03/09/2017 04:26 PM, Segher Boessenkool wrote:
> That looks correct.  Okay for trunk, thanks!  Does it need backporting
> as well?

The -mupper-regs-di support is new in GCC 7 and I verified the testcase
compiles fine with GCC 5/6, so no backporting necessary.

-Pat
diff mbox

Patch

Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c	(revision 245961)
+++ config/rs6000/rs6000.c	(working copy)
@@ -3182,7 +3182,7 @@  rs6000_init_hard_regno_mode_ok (bool glo
       else
 	rs6000_constraints[RS6000_CONSTRAINT_ws] = FLOAT_REGS;

-      if (TARGET_UPPER_REGS_DF)					/* DImode  */
+      if (TARGET_UPPER_REGS_DI)					/* DImode  */
 	rs6000_constraints[RS6000_CONSTRAINT_wi] = VSX_REGS;
       else
 	rs6000_constraints[RS6000_CONSTRAINT_wi] = FLOAT_REGS;
Index: testsuite/gcc.target/powerpc/pr79907.c
===================================================================
--- testsuite/gcc.target/powerpc/pr79907.c	(nonexistent)
+++ testsuite/gcc.target/powerpc/pr79907.c	(working copy)
@@ -0,0 +1,15 @@ 
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" }
{ "-mcpu=power8" } } */
+/* { dg-options "-mcpu=power8 -O3 -mno-upper-regs-df" } */
+
+int foo (short a[], int x)
+{
+  unsigned int i;
+  for (i = 0; i < 1000; i++)
+    {
+      x = a[i];
+      a[i] = (x <= 0 ? 0 : x);
+    }
+  return x;