https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100113
Bug ID: 100113
Summary: missed optimization for dead code elimination at -O3
(vs. -O1)
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: ---
[584] % 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 20210416 (experimental) [master revision
89c863488bc:10ed13839be:76c7e7d6b003a17d183d0571bf9b34c691819d25] (GCC)
[585] %
[585] % gcctk -O1 -S -o O1.s small.c
[586] % gcctk -O3 -S -o O3.s small.c
[587] %
[587] % wc O1.s O3.s
84 185 1140 O1.s
120 254 1768 O3.s
204 439 2908 total
[588] %
[588] % grep foo O1.s
[589] % grep foo O3.s
call foo
[590] %
[590] % cat small.c
extern void foo(void);
int a, b, d, *c = &a, e, k;
static int f(int *h, int i, int **l) {
for (b = 0; b < 1; b++) {
int *f = &d;
for (; d < 1; d++)
f = c;
if (f != &a)
__builtin_abort();
if (k)
*c = 0;
}
*c = 0;
return **l;
}
int main() {
int *j = &b;
if (!f(j, e, &j))
foo();
return 0;
}