https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99788
Bug ID: 99788 Summary: missed optimization for dead code elimination at -O3 (vs. -O1) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: zhendong.su at inf dot ethz.ch CC: marxin at gcc dot gnu.org Target Milestone: --- [606] % 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 20210326 (experimental) [master revision 9d45e848d02:ca344bbd24f:6081d8994ed1a0aef6b7f5fb34f091faa3580416] (GCC) [607] % [607] % gcctk -O1 -S -o O1.s small.c [608] % gcctk -O3 -S -o O3.s small.c [609] % [609] % wc O1.s O3.s 79 162 986 O1.s 109 229 1433 O3.s 188 391 2419 total [610] % [610] % grep foo O1.s [611] % grep foo O3.s call foo [612] % [612] % cat small.c extern void foo(void); char a; int b, *c, g, h = 1, i = 1, j, *k = &i; static void d(); static int *e() { for (a = 1; a; a = a+2) ; foo(); h = (g % h) % i; *k = -j; return 0; } static void f() { if (b) d(e); } void d() { for (;;) c = e(); } int main() { f(); return 0; }