https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110228
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|[14 Regression] llvm-16 |[13/14 Regression] llvm-16 |miscompiled due to an maybe |miscompiled due to an maybe |uninitialized and |uninitialized and |optimizations saying that |optimizations saying that |the uninitialized has a |the uninitialized has a |nonzero bits of 1. |nonzero bits of 1. Target Milestone|14.0 |13.2 --- Comment #16 from Andrew Pinski <pinskia at gcc dot gnu.org> --- here is a (x86_64 as it requires the inline-asm to force an undefined value inside LookupFlags but LookupFlags is not used until the next iteration) program which we have been miscompiling -O2 since r13-4459-g6508d5e5a1a8: ``` unsigned a[4] = {1,1,1,1}; unsigned tt1 = 0; __attribute__((noipa)) static void bug(unsigned & p, unsigned *t, int n, int t2) { for(int i = 0; i < n; i++) { bool LookupFlags ; unsigned v = t[i]; unsigned tt = tt1; if (v == 0) LookupFlags = 0; else if (v == 1) LookupFlags = 1; if (LookupFlags) { tt|=3u; LookupFlags = 0; } asm("movq $-1, %q1":"+a"(LookupFlags)); p = tt; } } int main() { unsigned r = 42; bug(r,a, sizeof(a)/sizeof(a[0]), 1); __builtin_printf("%u\n", r); if (r != 3) __builtin_abort(); } ``` Yes it is a bit odd but that was the only way I could get the code added in r13-4459-g6508d5e5a1a8 to be invoked and even have LookupFlags|=v==1 happening and get what could get undefined behavior in the loop.