https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100359
Bug ID: 100359
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: ---
This seems to be a very recent regression as it does not reproduce for GCC 11.1
(and earlier).
[524] % 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 20210430 (experimental) [master revision
4cf3b10f27b:939d67a66c9:c111f6066043d3b7bc4141ca0411eae9294aa6c5] (GCC)
[525] %
[525] % gcctk -O2 -S -o O2.s small.c
[526] % gcctk -O3 -S -o O3.s small.c
[527] %
[527] % wc O2.s O3.s
37 83 635 O2.s
49 109 808 O3.s
86 192 1443 total
[528] %
[528] % grep foo O2.s
[529] % grep foo O3.s
call foo
[530] %
[530] % cat small.c
extern void foo(void);
static int b, f, *a = &b;
int **c = &a;
static void d() {
int g, h;
for (f = 0; f < 1; f++) {
int *i = &b;
{
int *j[3], **k = &a;
for (g = 0; g < 3; g++)
for (h = 0; h < 1; h++)
j[g] = &b;
*k = j[0];
}
*c = i;
}
}
int main() {
d();
*a = 0;
if (**c)
foo();
return 0;
}