In the commit titled 'doloop: Add support for predicated vectorized loops' the doloop_condition_get function was changed to accept loops with decrements larger than 1. This patch rejects such loops for modulo-sched.

I've put the test for this in the aarch64 testsuite, but I just realized even though the testcase failed for aarch64, it can and should run on any target that supports BitInt, should I move it to dg and add a target { bitint } ? PS: I have not checked whether the testcase used to fail in other targets.

Bootstrapped and regtested aarch64-none-linux-gnu, arm-none-linux-gnueabihf, x86_64-pc-linux-gnu.

OK for trunk (and backport to 15 branch)?

gcc/ChangeLog:

        PR rtl-optimization/116479
        * modulo-sched.cc (doloop_register_get): Reject conditions with
        decrements that are not 1.

gcc/testsuite/ChangeLog:

        * gcc.target/aarch64/pr116479.c: New test.
diff --git a/gcc/modulo-sched.cc b/gcc/modulo-sched.cc
index 
08af5a929e148df8b3f6f4f9c4ada564aac22cdb..002346778f447ffe4fbad803872ba03880236e34
 100644
--- a/gcc/modulo-sched.cc
+++ b/gcc/modulo-sched.cc
@@ -356,7 +356,13 @@ doloop_register_get (rtx_insn *head, rtx_insn *tail)
     reg = XEXP (condition, 0);
   else if (GET_CODE (XEXP (condition, 0)) == PLUS
           && REG_P (XEXP (XEXP (condition, 0), 0)))
-    reg = XEXP (XEXP (condition, 0), 0);
+    {
+      if (CONST_INT_P (XEXP (condition, 1))
+         && INTVAL (XEXP (condition, 1)) == -1)
+       reg = XEXP (XEXP (condition, 0), 0);
+      else
+       return NULL_RTX;
+    }
   else
     gcc_unreachable ();
 
diff --git a/gcc/testsuite/gcc.target/aarch64/pr116479.c 
b/gcc/testsuite/gcc.target/aarch64/pr116479.c
new file mode 100644
index 
0000000000000000000000000000000000000000..73315c7f4d6ea93587a9a042289004782aa92190
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr116479.c
@@ -0,0 +1,20 @@
+/* PR 116479 */
+/* { dg-do run } */
+/* { dg-additional-options "-O -funroll-loops -finline-stringops 
-fmodulo-sched --param=max-iterations-computation-cost=637924687 -static 
-std=c23" } */
+_BitInt (13577) b;
+
+void
+foo (char *ret)
+{
+  __builtin_memset (&b, 4, 697);
+  *ret = 0;
+}
+
+int
+main ()
+{
+  char x;
+  foo (&x);
+  for (unsigned i = 0; i < sizeof (x); i++)
+    __builtin_printf ("%02x", i[(volatile unsigned char *) &x]);
+}

Reply via email to