https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111293
Bug ID: 111293 Summary: [14 Regression] Missed Dead Code Elimination since r14-3414-g0cfc9c953d0 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/9aj7sr5d6 Given the following code: void foo(void); static int a, d; static short e; static int(f)(int b, int c) { return c == 0 ? b : b / c; } static char g(char h) { char i = 1; int j = 8; e = 3; for (; d; ++d) { if (f(0 == j, e)) return a; for (; i; i--) { if (j) { if (e) ; else if (a) continue; else foo(); j = -h; break; } __builtin_unreachable(); break; } } return 1; } int main() { g(-1); a = e; } gcc-trunk -O2 does not eliminate the call to foo: main: subq $8, %rsp movl d(%rip), %ecx movl $3, %edx movw %dx, e(%rip) testl %ecx, %ecx je .L6 movl $3, %edx .p2align 4,,10 .p2align 3 .L2: testw %dx, %dx jne .L3 movl a(%rip), %eax testl %eax, %eax je .L18 .L5: addl $1, d(%rip) jne .L5 .L6: movswl e(%rip), %eax movl %eax, a(%rip) xorl %eax, %eax addq $8, %rsp ret .p2align 4,,10 .p2align 3 .L18: call foo .L3: addl $1, d(%rip) movzwl e(%rip), %edx jne .L2 jmp .L6 gcc-13.2.0 -O2 eliminates the call to foo: main: movl d(%rip), %edx movl $3, %eax movw %ax, e(%rip) testl %edx, %edx je .L3 movl $0, d(%rip) .L3: movl $3, a(%rip) xorl %eax, %eax ret Bisects to r14-3414-g0cfc9c953d0