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

            Bug ID: 100100
           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: ---

[538] % 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 20210415 (experimental) [master revision
4dd9e1c541e:7315804b0a0:b5f644a98b3f3543d3a8d2dfea7785c22879013f] (GCC) 
[539] % 
[539] % gcctk -O1 -S -o O1.s small.c
[540] % gcctk -O3 -S -o O3.s small.c
[541] % 
[541] % wc O1.s O3.s
  79  175 1126 O1.s
  98  196 1466 O3.s
 177  371 2592 total
[542] % 
[542] % grep foo O1.s
[543] % grep foo O3.s
        jmp     foo
[544] % 
[544] % cat small.c
extern void foo(void);
static int a, d, e, h, o, p;
static short b, c, f, *i = &b;
static char g;
static void l() {
  d = 0;
  for (; d < 4; d++)
    for (; f; f++)
      c = 0;
  for (; c; c++)
    ;
}
static void k(unsigned short q) {
  l();
  for (; g; g++)
    h = e == p;
}
static void j(int q) {
  k(q);
  unsigned char m = q;
  o = m;
  if (m)
    foo();
}
void n() {
  j(a);
  *i = 0;
}
int main() {
  n();
  return 0;
}
  • [Bug ipa/100100] New: missed o... zhendong.su at inf dot ethz.ch via Gcc-bugs

Reply via email to