https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103399
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2021-11-24 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed reduced testcase: int t1 = -2; int e(int) __attribute__((noipa)); int e(int f) { int t = 0; for (int d = 0; d < f; d ++) { for (int c = 0; c < ((f ? t1 : 0) ^ t1) + 1; c++) t= 42; } return t; } int main() { unsigned a = e(1); printf("%u\n", a); if (a != 42) __builtin_abort (); } Note the t1 being negative is important. t1 being global is also important, if you do a load of t1 before either loop, you end up with working code. THis is another bswap issue ...