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

            Bug ID: 99862
           Summary: [meta-issue] various missed optimizations for dead
                    code elimination
           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: ---

[561] % 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 20210401 (experimental) [master revision
e4bb1bd60a9:c23a685bf70:95d217ab52d31dc06fda42fc136dea165909e88b] (GCC) 
[562] % 
[562] % gcctk -O1 -S -o O1.s small.c
[563] % gcctk -O3 -S -o O3.s small.c
[564] % 
[564] % wc O1.s O3.s
  23   45  420 O1.s
  39   74  669 O3.s
  62  119 1089 total
[565] % 
[565] % grep foo O1.s
[566] % grep foo O3.s
        call    foo
[567] % 
[567] % cat small.c
extern void foo(void);
static int a, b;
static int c() {
  foo();
  while (1)
    while (b)
      foo();
}
void d() {
  if (a)
    c();
}
int main() {
  d();
  return 0;
}

Reply via email to