]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR118017][LRA]: Don't inherit reg of non-uniform reg class
authorVladimir N. Makarov <vmakarov@redhat.com>
Thu, 9 Jan 2025 21:22:02 +0000 (16:22 -0500)
committerVladimir N. Makarov <vmakarov@redhat.com>
Thu, 9 Jan 2025 21:27:28 +0000 (16:27 -0500)
In the PR case LRA inherited value of register of class INT_SSE_REGS
which resulted in LRA cycling when LRA tried to use different move
alternatives with SSE/general regs and memory.  The patch rejects to
inherit such (non-uniform) classes to prevent cycling.

gcc/ChangeLog:

PR target/118017
* lra-constraints.cc (inherit_reload_reg): Check reg class on uniformity.

gcc/testsuite/ChangeLog:

PR target/118017
* gcc.target/i386/pr118017.c: New.

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

index a0f05b290dde1dd98c0b7d04783ae73254b0cdb5..8f32e98f1c47e5fd6fb5835cf44233c4299a4d6e 100644 (file)
@@ -5878,6 +5878,20 @@ inherit_reload_reg (bool def_p, int original_regno,
        }
       return false;
     }
+  if (ira_reg_class_min_nregs[rclass][GET_MODE (original_reg)]
+      != ira_reg_class_max_nregs[rclass][GET_MODE (original_reg)])
+    {
+      if (lra_dump_file != NULL)
+       {
+         fprintf (lra_dump_file,
+                  "    Rejecting inheritance for %d "
+                  "because of requiring non-uniform class %s\n",
+                  original_regno, reg_class_names[rclass]);
+         fprintf (lra_dump_file,
+                  "    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+       }
+      return false;
+    }
   new_reg = lra_create_new_reg (GET_MODE (original_reg), original_reg,
                                rclass, NULL, "inheritance");
   start_sequence ();
diff --git a/gcc/testsuite/gcc.target/i386/pr118017.c b/gcc/testsuite/gcc.target/i386/pr118017.c
new file mode 100644 (file)
index 0000000..c82d71e
--- /dev/null
@@ -0,0 +1,21 @@
+/* PR target/118017 */
+/* { dg-do compile } */
+/* { dg-options "-Og -frounding-math -mno-80387 -mno-mmx -Wno-psabi" } */
+
+typedef __attribute__((__vector_size__ (64))) _Float128 F;
+typedef __attribute__((__vector_size__ (64))) _Decimal64 G;
+typedef __attribute__((__vector_size__ (64))) _Decimal128 H;
+
+void
+bar(_Float32, _BitInt(1025), _BitInt(1025), _Float128, __int128, __int128,  F,
+        int, int, G, _Float64, __int128, __int128, H, F);
+
+
+void
+foo ()
+{
+  bar ((__int128)68435455, 0, 0, 0, 0, 0, (F){}, 0, 0, (G){3689348814741910323},
+       0, 0, 0, (H){0, (_Decimal128) ((__int128) 860933398830926 << 64),
+       (_Decimal128) ((__int128) 966483857959145 << 64), 4},
+       (F){(__int128) 3689348814741910323 << 64 | 3});
+}