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

            Bug ID: 110931
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-2890-gcc2003cd875
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theodort at inf dot ethz.ch
  Target Milestone: ---

https://godbolt.org/z/zPTeo8Mj9

Given the following code:

void foo(void);
static int a = 7, c;
static int *d = &a, *e;
static int **f = &e;
static short g;
static char(h)(char b) {
    if (!(((b) >= 1) && ((b) <= 1))) {
        __builtin_unreachable();
    }
    return 0;
}
static void k(unsigned i) {
    short j = i;
    if (j)
        ;
    else {
        h(i);
        if ((e && i) <= 0)
            ;
        else
            foo();
        *f = &c;
    }
    h(0 >= 0);
}
int main() {
    int l = *d;
    g = l;
    k(g);
}

gcc-trunk -O3 does not eliminate the call to foo:

main:
        cmpw    $0, a(%rip)
        jne     .L5
        cmpq    $0, e(%rip)
        je      .L6
        pushq   %rax
        call    foo
        xorl    %eax, %eax
        movq    $c, e(%rip)
        popq    %rdx
        ret
.L6:
        movq    $c, e(%rip)
.L5:
        xorl    %eax, %eax
        ret

gcc-13.2.0 -O3 eliminates the call to foo:

main:
        xorl    %eax, %eax
        ret

Bisects to r14-2890-gcc2003cd875

Reply via email to