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

            Bug ID: 100191
           Summary: missed optimization for dead code elimination at -O3
                    (vs. -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/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 20210421 (experimental) [master revision
7f9b7ccf0c1:344da81f015:5445da1a94bb4df752209e54f4aa21702609a20a] (GCC)
[539] %
[539] % gcctk -O2 -S -o O2.s small.c
[540] % gcctk -O3 -S -o O3.s small.c
[541] %
[541] % wc O2.s O3.s
  38   73  629 O2.s
  48   96  769 O3.s
  86  169 1398 total
[542] %
[542] % grep foo O2.s
[543] % grep foo O3.s
        jmp     foo
[544] %
[544] % cat small.c
extern void foo(void);
static int a, b, d, *e;
int c(int f) { return f < 0 || a || f; }
static int *g() {
  int *l[24], j = 0;
  for (; j < 6; j++)
    l[j] = &d;
  return l[0];
}
static inline int k() {
  long c[48] = {9};
  while (1)
    if (c[b])
      return 0;
}
static void i() {
  k();
  e = g();
}
static void h(int f) {
  i();
  if (!f)
    foo();
}
int main() {
  int m = c(1);
  h(m);
  return 0;
}
  • [Bug ipa/100191] New: missed o... zhendong.su at inf dot ethz.ch via Gcc-bugs

Reply via email to