https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100145
Bug ID: 100145 Summary: missed optimization for dead code elimination at -O3 (vs. -O2) 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: --- [639] % 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/11.0.1/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 11.0.1 20210419 (experimental) [master revision b412ce8e961:756887f4cee:d64720a07f611c55e8c815c775a852d650a2e738] (GCC) [640] % [640] % gcctk -O2 -S -o O2.s small.c [641] % gcctk -O3 -S -o O3.s small.c [642] % [642] % wc O2.s O3.s 77 164 1080 O2.s 88 187 1234 O3.s 165 351 2314 total [643] % [643] % grep foo O2.s [644] % grep foo O3.s call foo [645] % [645] % cat small.c int b, c, d, e; void foo(); int a(int f, int p) { return (p && f) || (f && p < 0 && p + 1) ? 0 : f + p; } static int g() { int *h = &c; *h = 0; if (b) { int *i = &e; while (1) { *h = a(0, i != 0); if (*h) return 0; } } return 0; } int main() { int *k = &c; g(); d = 1; if (*k > 100) foo(); return 0; }