Differences from v1:
Made suggested changes to testcase and moved to target-agnostic area.
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.
On 23/04/2025 16:51, Jakub Jelinek wrote:
On Wed, Apr 23, 2025 at 04:46:04PM +0100, Andre Vieira (lists) wrote:
On 23/04/2025 16:22, Jakub Jelinek wrote:
On Wed, Apr 23, 2025 at 03:57:58PM +0100, Andre Vieira (lists) wrote:
+++ 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]);
Shouldn't these 2 lines instead be
if (x != 0)
__builtin_abort ();
?
Fair, I copied the testcase verbatim from the PR, the error-mode was a
segfault. But I agree a check !=0 with __builtin_abort here seems more
appropriate. Any opinions on whether I should move it to dg with a bitint
target?
I think there isn't anything aarch64 specific on the test, so yes,
I'd move it to gcc/testsuite/gcc.dg/bitint-123.c,
/* { dg-do run { target bitint } } */
and wrap b/foo definitions into #if __BITINT_MAXWIDTH__ >= 13577
and the main body as well (just in case some target supports smaller maximum
width than that).
Also, drop -static from dg-additional-options?
Jakub
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.dg/pr116479.c b/gcc/testsuite/gcc.dg/pr116479.c
new file mode 100644
index
0000000000000000000000000000000000000000..dbbcb9aaf5753c500d56aa2e12c2c34cf8d5d6d4
--- /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
+}