https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121648
Bug ID: 121648 Summary: wrong code at -O{s,2,3} with "-fno-tree-loop-im -fno-gcse -fno-code-hoisting -fno-tree-fre -fno-tree-pre -fno-tree-dominator-opts" 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: --- Compiler Explorer: https://godbolt.org/z/KPKbdhbKb Note: - works: 10.5 and earlier - fails: 11.1 and later - -fno-tree-slsr and -fno-ivopts do not make it disappear [992] % gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.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 16.0.0 20250823 (experimental) (GCC) [993] % [993] % gcctk -O3 small.c; ./a.out [994] % gcctk -O3 -fno-tree-loop-im -fno-gcse -fno-code-hoisting -fno-tree-fre -fno-tree-pre -fno-tree-dominator-opts small.c [995] % ./a.out Aborted [996] % cat small.c int a = -2; int main() { int b = -2, c = 12 / a; do { if (3 / c) b = 0; } while (3 / c); int d[] = {b, -2, 1 - 3 % c}; for (int e = 0; e < 3; e++) if (d[e] != a) __builtin_abort(); return 0; }