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  <pthau...@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  <pthau...@us.ibm.com>

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



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;
+}

Reply via email to