https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110941
Bug ID: 110941 Summary: [14 Regression] Dead Code Elimination Regression at -O3 since r14-2379-gc496d15954c 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 int a; void foo(void); void bar349_(void); void bar363_(void); void bar275_(void); int main() { { { short b = 26; for (; b >= 1; b = b - 4) { if (b >= 2 && b <= 26) bar275_(); if (a) bar363_(); if (a) bar349_(); int c = b; if (!(c >= 2 && c <= 26)) foo(); } } a = 0; } } gcc-25c4b1620eb (trunk) -O3 cannot eliminate the call to foo but gcc-releases/gcc-13.1.0 -O3 can. ----------------------------------------------------------------------- gcc-25c4b1620ebc10fceabd86a34fdbbaf8037e7e82 -O3 case.c -S -o case.s --------- OUTPUT --------- main: .LFB0: .cfi_startproc pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movl $24, %ebx .p2align 4,,10 .p2align 3 .L8: cmpw $24, %bx jbe .L2 movl a(%rip), %edx testl %edx, %edx jne .L3 .L7: call foo xorl %eax, %eax popq %rbx .cfi_remember_state .cfi_def_cfa_offset 8 movl $0, a(%rip) ret .p2align 4,,10 .p2align 3 .L3: .cfi_restore_state call bar363_ movl a(%rip), %eax testl %eax, %eax je .L7 call bar349_ jmp .L7 .L2: call bar275_ cmpl $0, a(%rip) jne .L15 .p2align 4,,10 .p2align 3 .L6: subl $4, %ebx cmpl $-4, %ebx jne .L8 movl $0, a(%rip) xorl %eax, %eax popq %rbx .cfi_remember_state .cfi_def_cfa_offset 8 ret .L15: .cfi_restore_state call bar363_ cmpl $0, a(%rip) je .L6 call bar349_ cmpl $24, %ebx jbe .L6 jmp .L7 ---------- END OUTPUT --------- ----------------------------------------------------------------------- gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O3 case.c -S -o case.s --------- OUTPUT --------- main: .LFB0: .cfi_startproc pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movl $24, %ebx .L10: cmpw $24, %bx jbe .L2 movl a(%rip), %edx testl %edx, %edx jne .L17 .L3: movl $0, a(%rip) xorl %eax, %eax popq %rbx .cfi_remember_state .cfi_def_cfa_offset 8 ret .p2align 4,,10 .p2align 3 .L17: .cfi_restore_state call bar363_ movl a(%rip), %eax testl %eax, %eax jne .L4 .L15: subl $4, %ebx jmp .L10 .p2align 4,,10 .p2align 3 .L4: call bar349_ jmp .L15 .L2: call bar275_ cmpl $0, a(%rip) jne .L18 .p2align 4,,10 .p2align 3 .L9: subl $4, %ebx cmpw $-4, %bx jne .L10 jmp .L3 .L18: call bar363_ cmpl $0, a(%rip) je .L9 call bar349_ jmp .L9 ---------- END OUTPUT --------- ----------------------------------------------------------------------- Bisects to r14-2379-gc496d15954c