https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101223
Bug ID: 101223 Summary: wrong code at -Os and above 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: --- It also affects GCC 11.*, but not GCC 10.*. [516] % 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/12.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20210626 (experimental) [master revision 2168bfb8144:f9d3bc42803:5b1ce655b25040048861af6c0264cb667b66fcd7] (GCC) [517] % [517] % gcctk -O1 small.c; ./a.out [518] % [518] % gcctk -Os small.c [519] % ./a.out Aborted [520] % [520] % cat small.c struct { int a : 1; } b; int c = 1, d; int main() { for (; d < 2; d++) { int e = ~c, f = 0, g; if (e) { f = c; g = b.a; b.a = f; if (b.a >= g) __builtin_abort(); } c = f; b.a = g; } return 0; }