https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100220

            Bug ID: 100220
           Summary: missed optimization for dead code elimination at -O3
                    (vs. -O1, -Os, -O2)
           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: ---

[638] % 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 20210422 (experimental) [master revision
3cf04d1afa8:0e51007a40c:d42088e453042f4f8ba9190a7e29efd937ea2181] (GCC) 
[639] % 
[639] % gcctk -O1 -S -o O1.s small.c
[640] % gcctk -O3 -S -o O3.s small.c
[641] % 
[641] % wc O1.s O3.s
  62  135  857 O1.s
  93  200 1337 O3.s
 155  335 2194 total
[642] % 
[642] % grep foo O1.s
[643] % grep foo O3.s
        call    foo
[644] % 
[644] % cat small.c
extern void foo(void);
int b, c, d, e, *h;
static int *f = &e;
static int a() { return 1; }
static void g() {
  if (!*f)
    for (; 1; d++)
      ;
  foo();
}
static void i() {
  int j, l = 0, k[24] = {0}, *m[2] = {&k[4], &l}, n[27];
  h = n;
  if (a() & n[0])
    for (; c; c--)
      ;
  int p[8];
  h = p;
  p[0] && (h = &j);
  e = 0;
}
static void o() {
  int *q, **r = &q, ***s[1];
  s[0] = &r;
  i();
  g();
}
int main() {
  if (b)
    o();
  return 0;
}

Reply via email to