Skip to content

Commit 8073fa1

Browse files
committed
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.
1 parent 3d156c9 commit 8073fa1

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

gcc/modulo-sched.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,13 @@ doloop_register_get (rtx_insn *head, rtx_insn *tail)
356356
reg = XEXP (condition, 0);
357357
else if (GET_CODE (XEXP (condition, 0)) == PLUS
358358
&& REG_P (XEXP (XEXP (condition, 0), 0)))
359-
reg = XEXP (XEXP (condition, 0), 0);
359+
{
360+
if (CONST_INT_P (XEXP (condition, 1))
361+
&& INTVAL (XEXP (condition, 1)) == -1)
362+
reg = XEXP (XEXP (condition, 0), 0);
363+
else
364+
return NULL_RTX;
365+
}
360366
else
361367
gcc_unreachable ();
362368

gcc/testsuite/gcc.dg/pr116479.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* PR 116479 */
2+
/* { dg-do run { target { bitint } } } */
3+
/* { dg-additional-options "-O -funroll-loops -finline-stringops -fmodulo-sched --param=max-iterations-computation-cost=637924687 -std=c23" } */
4+
5+
#if __BITINT_MAXWIDTH__ >= 13577
6+
_BitInt (13577) b;
7+
8+
void
9+
foo (char *ret)
10+
{
11+
__builtin_memset (&b, 4, 697);
12+
*ret = 0;
13+
}
14+
#endif
15+
16+
int
17+
main ()
18+
{
19+
#if __BITINT_MAXWIDTH__ >= 13577
20+
char x;
21+
foo (&x);
22+
for (unsigned i = 0; i < sizeof (x); i++)
23+
if (x != 0)
24+
__builtin_abort ();
25+
#endif
26+
}

0 commit comments

Comments
 (0)