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

            Bug ID: 111457
           Summary: [14 Regression] Dead Code Elimination Regression since
                    r14-3407-g936a12331a2
           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/j4M8z8MzK

Given the following code:

void foo(void);
static int a, b, c, d, h;
static short i;
static void e(int f) {
    int g = -16;
    for (; g != -6; g = g + 5) {
        b = 6;
        if (!(((f) >= 1) && ((f) <= 26))) {
            __builtin_unreachable();
        }
        f = 0;
        for (; f < 26; ++f)
            if (a) {
                foo();
                break;
            }
        d = 0;
    }
}
int main() {
    a = 0;
    e(0 == i);
    h = d;
    c = b;
}

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

main:
        movl    $0, a(%rip)
        pushq   %rbx
        movl    $2, %ebx
.L3:
        movl    $6, b(%rip)
        movl    a(%rip), %eax
        testl   %eax, %eax
        je      .L2
        call    foo
.L2:
        movl    $0, d(%rip)
        cmpl    $1, %ebx
        jne     .L4
        xorl    %eax, %eax
        popq    %rbx
        ret
        .p2align 4,,10
        .p2align 3
.L4:
        movl    $1, %ebx
        jmp     .L3

gcc-13.2.0 -O2 eliminates the call to foo:

main:
        movl    $0, a(%rip)
        xorl    %eax, %eax
        movl    $6, b(%rip)
        movl    $0, d(%rip)
        ret

Bisects to r14-3407-g936a12331a2

Reply via email to