https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107523
Bug ID: 107523 Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zhendong.su at inf dot ethz.ch Target Milestone: --- This appears to be a recent regression as 12.2 compiles the test correctly. Compiler Explorer: https://godbolt.org/z/1erPMzzjK [522] % gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk --enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20221104 (experimental) [master r13-3645-gfabe470b244] (GCC) [523] % [523] % gcctk -Os small.c; ./a.out [524] % [524] % gcctk -O2 small.c [525] % ./a.out Floating point exception [526] % [526] % cat small.c int a, b = 1; unsigned int c = 1; int main() { int d = 1, f; if (b) d = 0; a = -1; b = ~d ^ 465984011; L1:; if (b < 2) f = b; b = f; if (f <= a) { int g = -(a && 1), h = g - f && a, i = ~(c / f) && 1 % (a | h); if (c) { g = f; if (i || (g && (g > -465984012))) goto L2; } c = g | f / c; } if (0) L2: a = 0; if (a <= c) goto L1; return 0; }