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

            Bug ID: 110919
           Summary: [14 Regression] Dead Code Elimination Regression at
                    -O3 since r14-1691-gbc5a2c2e793
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: scherrer.sv at gmail dot com
  Target Milestone: ---

static short a, b;
static int e;
static int *j = &e;
void bar151_(void);
void foo(void);
void bar162_(void);
static int(d)(int k, int l) { return l == k && l - 1 ? k : 0; }
static void f();
static void g(unsigned short, unsigned);
static void h() {
  g(0, 4);
  f();
  int i = -1;
  g(0, i);
}
static void f(int k) { g(k, 0); }
static void g(unsigned short k, unsigned l) {
  if (k)
    bar151_();
  if (l)
    if (k)
      bar162_();
  short c = l;
  b = c == 0 || a;
  if (d(*j, b))
    foo();
}
int main() { h(); }

gcc-87b0749cfb9 (trunk) -O3 cannot eliminate the call to foo but
gcc-releases/gcc-13.1.0 -O3 can.
-----------------------------------------------------------------------
gcc-87b0749cfb9406790b108208b466cf507ae3c431 -O3 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB4:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        movl    $4, %esi
        xorl    %edi, %edi
        call    g
        xorl    %esi, %esi
        xorl    %edi, %edi
        call    g
        movl    $-1, %esi
        xorl    %edi, %edi
        call    g
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------

-----------------------------------------------------------------------
gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s
--------- OUTPUT ---------
main:
.LFB4:
        .cfi_startproc
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        movl    $4, %esi
        xorl    %edi, %edi
        call    g
        xorl    %esi, %esi
        xorl    %edi, %edi
        call    g
        movl    $-1, %esi
        xorl    %edi, %edi
        call    g
        xorl    %eax, %eax
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
---------- END OUTPUT ---------

-----------------------------------------------------------------------
Bisects to r14-1691-gbc5a2c2e793

Reply via email to