https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106523
Bug ID: 106523 Summary: forwprop miscompile Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- The function f7 from testsuite/c-c++-common/rotate-2.c is miscompiled by forwprop. This can be seen by running the function as __attribute__((noinline)) unsigned char f7 (unsigned char x, unsigned int y) { unsigned int t = x; return (t << y) | (t >> ((-y) & 7)); } int main (void) { volatile unsigned char x = 152; volatile unsigned int y = 19; if (f7(x, y) != 4) __builtin_abort (); return 0; } This fails at -O1 and higher optimization levels. What is happening here is that forwprop1 has optimized the function to _10 = x_7(D) r<< y_9(D); return _10;