https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99776
Bug ID: 99776
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: ---
[687] % 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 20210325 (experimental) [master revision
08103e4d6ad:4e4f8ee0bf5:a29124d28253cdf603ba1977db2f09c9f233fea5] (GCC)
[688] %
[688] % gcctk -O1 -S -o small_O1.s small.c
[689] % gcctk -O3 -S -o small_O3.s small.c
[690] %
[690] % wc small_O1.s small_O3.s
23 52 455 small_O1.s
37 82 682 small_O3.s
60 134 1137 total
[691] %
[691] % grep foo small_O1.s
[692] % grep foo small_O3.s
call foo
[693] %
[693] % cat small.c
extern void foo(void);
static int a[2], b, *c[2];
int main() {
for (b = 0; b < 2; b++)
c[b] = &a[1];
if (!c[0])
foo();
return 0;
}