aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Vieira <andre.simoesdiasvieira@arm.com>2025-04-25 14:02:43 +0100
committerAndre Vieira <andre.simoesdiasvieira@arm.com>2025-04-25 14:02:43 +0100
commit8073fa147248aa67c11227f922d91d784659077e (patch)
treeccfd9c56094c7677022d3cc22f0c336c01657a56
parent3d156c9e9bdaf351f77e3348b7d0d75e08f65580 (diff)
downloadgcc-8073fa147248aa67c11227f922d91d784659077e.zip
gcc-8073fa147248aa67c11227f922d91d784659077e.tar.gz
gcc-8073fa147248aa67c11227f922d91d784659077e.tar.bz2
modulo-sched: reject loop conditions when not decrementing with one [PR 116479]
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. gcc/ChangeLog: PR rtl-optimization/116479 * modulo-sched.cc (doloop_register_get): Reject conditions with decrements that are not 1. gcc/testsuite/ChangeLog: * gcc.dg/pr116479.c: New test.
-rw-r--r--gcc/modulo-sched.cc8
-rw-r--r--gcc/testsuite/gcc.dg/pr116479.c26
2 files changed, 33 insertions, 1 deletions
diff --git a/gcc/modulo-sched.cc b/gcc/modulo-sched.cc
index 08af5a9..0023467 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.dg/pr116479.c b/gcc/testsuite/gcc.dg/pr116479.c
new file mode 100644
index 0000000..dbbcb9a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr116479.c
@@ -0,0 +1,26 @@
+/* PR 116479 */
+/* { dg-do run { target { bitint } } } */
+/* { dg-additional-options "-O -funroll-loops -finline-stringops -fmodulo-sched --param=max-iterations-computation-cost=637924687 -std=c23" } */
+
+#if __BITINT_MAXWIDTH__ >= 13577
+_BitInt (13577) b;
+
+void
+foo (char *ret)
+{
+ __builtin_memset (&b, 4, 697);
+ *ret = 0;
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 13577
+ char x;
+ foo (&x);
+ for (unsigned i = 0; i < sizeof (x); i++)
+ if (x != 0)
+ __builtin_abort ();
+#endif
+}