https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115661
Bug ID: 115661 Summary: wrong code at -O{2,3} 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 it doesn't reproduce with 14.1. Compiler Explorer: https://godbolt.org/z/1dneGGoTE [517] % 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/15.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 Thread model: posix Supported LTO compression algorithms: zlib gcc version 15.0.0 20240626 (experimental) (GCC) [518] % [518] % gcctk -O0 small.c; ./a.out [519] % gcctk -O2 small.c [520] % ./a.out 0 [521] % cat small.c int printf(const char *, ...); int a, b[6], c = 2, d, e = 446984904, *g, h, *i = &b[5]; int *m() { int *f = &c; if (d < 6) return &b[5]; return f; } void n() { int j; for (; a < 1; a++) for (j = 0; j < 1; j++) { g = m(); int k = *g; if (k) { int l = (3504049682 + e) & 3504049682; h = ~(k * l) * 7455084268; if (h > -1436818931) { printf("0\n"); continue; } return; } } } int main() { *i = 1; n(); return 0; }