]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RA]: Fixing LRA cycling for multi-reg variable containing a fixed reg
authorVladimir N. Makarov <vmakarov@redhat.com>
Tue, 31 Oct 2023 14:54:43 +0000 (10:54 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Tue, 31 Oct 2023 15:45:40 +0000 (11:45 -0400)
PR111971 test case uses a multi-reg variable containing a fixed reg.  LRA
rejects such multi-reg because of this when matching the constraint for
an asm insn.  The rejection results in LRA cycling.  The patch fixes this issue.

gcc/ChangeLog:

PR rtl-optimization/111971
* lra-constraints.cc: (process_alt_operands): Don't check start
hard regs for regs originated from register variables.

gcc/testsuite/ChangeLog:

PR rtl-optimization/111971
* gcc.target/powerpc/pr111971.c: New test.

gcc/lra-constraints.cc
gcc/testsuite/gcc.target/powerpc/pr111971.c [new file with mode: 0644]

index d10a2a3dc5128a7d84db18cdd16a8eade98f09bf..0607c8be7cbb698234eaa47a698756513cd9ba03 100644 (file)
@@ -2609,12 +2609,15 @@ process_alt_operands (int only_alternative)
                  winreg = true;
                  if (REG_P (op))
                    {
+                     tree decl;
                      if (hard_regno[nop] >= 0
                          && in_hard_reg_set_p (this_alternative_set,
                                                mode, hard_regno[nop])
-                         && !TEST_HARD_REG_BIT
-                             (this_alternative_exclude_start_hard_regs,
-                              hard_regno[nop]))
+                         && ((REG_ATTRS (op) && (decl = REG_EXPR (op)) != NULL
+                              && VAR_P (decl) && DECL_HARD_REGISTER (decl))
+                             || !(TEST_HARD_REG_BIT
+                                  (this_alternative_exclude_start_hard_regs,
+                                   hard_regno[nop]))))
                        win = true;
                      else if (hard_regno[nop] < 0
                               && in_class_p (op, this_alternative, NULL))
diff --git a/gcc/testsuite/gcc.target/powerpc/pr111971.c b/gcc/testsuite/gcc.target/powerpc/pr111971.c
new file mode 100644 (file)
index 0000000..7f058bd
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+void
+foo (unsigned long long *a)
+{
+  register long long d asm ("r0") = 0x24;
+  long long n;
+  asm ("mr %0, %1" : "=r"(n) : "r"(d));
+  *a++ = n;
+}