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

            Bug ID: 105086
           Summary: Dead Code Elimination Regression at -Os (trunk vs.
                    11.2.0) 25
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yann at ywg dot ch
  Target Milestone: ---

Created attachment 52702
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52702&action=edit
The case presented.

cat case.c #25
void foo();
int main() {
  unsigned a = -23;
  for (; a >= 2; ++a)
    if (a == 55)
      foo();
}

`gcc-0127fb1b78a36a7b228d4b3fe32eedfc8d273363 (trunk) -Os` can not eliminate
`foo` but `gcc-releases/gcc-11.2.0 -Os` can.

`gcc-0127fb1b78a36a7b228d4b3fe32eedfc8d273363 (trunk) -Os -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        movl    $-23, %eax
.L6:
        cmpl    $55, %eax
        je      .L10
        incl    %eax
        jne     .L6
        xorl    %eax, %eax
        ret
.L10:
        pushq   %rax
        .cfi_def_cfa_offset 16
.L7:
        xorl    %eax, %eax
        call    foo
        movl    $56, %eax
.L2:
        incl    %eax
        je      .L12
        cmpl    $55, %eax
        jne     .L2
        jmp     .L7
.L12:
        xorl    %eax, %eax
        popq    %rdx
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------


`gcc-releases/gcc-11.2.0 -Os -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB0:
        .cfi_startproc
        xorl    %eax, %eax
        ret
---------- END OUTPUT ---------


Bisects to:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=502ffb1f389011b28ee51815242c7397790802d5

----- Build information -----
----- 0127fb1b78a36a7b228d4b3fe32eedfc8d273363 (trunk)
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
--prefix=/zdata/compiler_cache/gcc-0127fb1b78a36a7b228d4b3fe32eedfc8d273363
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220328 (experimental) (GCC)

----- releases/gcc-11.2.0
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
--prefix=/zdata/compiler_cache/gcc-01a9836c07053b3286b2259d6b628c7583413f55
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC)

Reply via email to