diff mbox series

[committed,PR97701] LRA: Don't narrow class only for REG or MEM. A version modified for gcc 10 branch.

Message ID 71258afa-6f7f-4544-682a-478c0937f74b@redhat.com
State New
Headers show
Series [committed,PR97701] LRA: Don't narrow class only for REG or MEM. A version modified for gcc 10 branch. | expand

Commit Message

Vladimir Makarov Feb. 4, 2021, 9:10 p.m. UTC
It seem that my recent patch for PR97701 for the trunk did not create 
new problems.  Therefore I am committing the following patch into 
gcc-10-branch.
diff mbox series

Patch

commit 4918937f4c76b05eaa331f8d6f2571e2fddcc22b (HEAD -> releases/gcc-10)
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Thu Feb 4 15:57:55 2021 -0500

    [PR97701] LRA: Don't narrow class only for REG or MEM.  A version modified for gcc-10.
    
    This is modified version of the patch committed for the trunk.  The
    modification for gcc-10 includes lra-constraint.c code and the test.
    
    gcc/ChangeLog:
    
            PR target/97701
            * lra-constraints.c (in_class_p): Don't narrow class only for REG
            or MEM.
    
    gcc/testsuite/ChangeLog:
    
            PR target/97701
            * gcc.target/aarch64/pr97701.c: New.

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 088208b9c6e..bf04eb48ba6 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -244,6 +244,7 @@  in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class)
 {
   enum reg_class rclass, common_class;
   machine_mode reg_mode;
+  rtx src;
   int class_size, hard_regno, nregs, i, j;
   int regno = REGNO (reg);
 
@@ -259,6 +260,7 @@  in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class)
     }
   reg_mode = GET_MODE (reg);
   rclass = get_reg_class (regno);
+  src = curr_insn_set != NULL ? SET_SRC (curr_insn_set) : NULL;
   if (regno < new_regno_start
       /* Do not allow the constraints for reload instructions to
 	 influence the classes of new pseudos.  These reloads are
@@ -266,12 +268,10 @@  in_class_p (rtx reg, enum reg_class cl, enum reg_class *new_class)
 	 reload pseudos for one alternative may lead to situations
 	 where other reload pseudos are no longer allocatable.  */
       || (INSN_UID (curr_insn) >= new_insn_uid_start
-	  && curr_insn_set != NULL
-	  && ((OBJECT_P (SET_SRC (curr_insn_set))
-	       && ! CONSTANT_P (SET_SRC (curr_insn_set)))
-	      || (GET_CODE (SET_SRC (curr_insn_set)) == SUBREG
-		  && OBJECT_P (SUBREG_REG (SET_SRC (curr_insn_set)))
-		  && ! CONSTANT_P (SUBREG_REG (SET_SRC (curr_insn_set)))))))
+	  && src != NULL
+	  && ((REG_P (src) || MEM_P (src))
+	      || (GET_CODE (src) == SUBREG
+		  && (REG_P (SUBREG_REG (src)) || MEM_P (SUBREG_REG (src)))))))
     /* When we don't know what class will be used finally for reload
        pseudos, we use ALL_REGS.  */
     return ((regno >= new_regno_start && rclass == ALL_REGS)
diff --git a/gcc/testsuite/gcc.target/aarch64/pr97701.c b/gcc/testsuite/gcc.target/aarch64/pr97701.c
new file mode 100644
index 00000000000..ede3540c48d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr97701.c
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+extern char a[][12][18][17][17];
+extern short b[][12][18][17][17];
+extern int c[][2][8][7];
+short *d;
+void e(signed f, int g, char h, char i, char j) {
+  for (int k = 648; k; k += f)
+    for (short l; l < j; l += 9)
+      for (long m = f + 6LL; m < (h ? h : i); m += 2)
+        for (int n = 0; n < 16; n += 3LL) {
+          for (int o = g; o; o++)
+            a[k][l][m][n][o] = b[k][l][m][n][o] = d[k] ? 2 : 0;
+          c[k][l][m][0] = 0;
+        }
+}