[Bug tree-optimization/108356] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0)

yann at ywg dot ch gcc-bugzilla@gcc.gnu.org
Tue Jan 10 12:50:54 GMT 2023


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

            Bug ID: 108356
           Summary: Dead Code Elimination Regression at -O2 (trunk vs.
                    12.2.0)
           Product: gcc
           Version: 13.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 54231
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54231&action=edit
presented code as file

cat case.c #93
char a;
static char c = 3;
char d;
void foo();
short(b)(short e, short f) { return e + f; }
int main() {
  unsigned g = 0;
  if (c)
    ;
  else
    foo();
  for (; g < 2; g = b(g, 2)) {
    d = g ? 0 : a;
    if (g)
      c = 0;
  }
}

`gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2` can not eliminate
`foo` but `gcc-releases/gcc-12.2.0 -O2` can.

`gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2 -S -o /dev/stdout
case.c`
--------- OUTPUT ---------
main:
.LFB1:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        cmpb    $0, c(%rip)
        je      .L6
.L4:
        movzbl  a(%rip), %eax
        movb    %al, d(%rip)
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        ret
.L6:
        .cfi_restore_state
        xorl    %eax, %eax
        call    foo
        jmp     .L4
---------- END OUTPUT ---------


`gcc-releases/gcc-12.2.0 -O2 -S -o /dev/stdout case.c`
--------- OUTPUT ---------
main:
.LFB1:
        .cfi_startproc
        movzbl  a(%rip), %eax
        movb    %al, d(%rip)
        xorl    %eax, %eax
        ret
---------- END OUTPUT ---------


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


More information about the Gcc-bugs mailing list