https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110413
Bug ID: 110413 Summary: [14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r14-1880-g827e208fa64 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/75vvarEvs Given the following code: void foo(void); static int a, b, d, e, g, h; static short f; static int *i, *k; static int **l = &i; void __assert_fail(char *, char *, int, char *) __attribute__((__noreturn__)); static int(c)() { return a + b; } static int *j() { f | e & 4073709551611 && c(); return &d; } int main() { *l = j(); h = 5; for (; h; h--) { k = j(); if (k && k <= &d) ; else { __builtin_unreachable(); __assert_fail("", "", 0, __PRETTY_FUNCTION__); } } if (k || k == &g) ; else foo(); ; } gcc-trunk -O1 does not eliminate the call to foo: j: movl $d, %eax ret main: subq $8, %rsp movl $0, %eax call j movq %rax, i(%rip) movq %rax, k(%rip) movl $0, h(%rip) cmpq $g, %rax je .L3 testq %rax, %rax je .L5 .L3: movl $0, %eax addq $8, %rsp ret .L5: call foo jmp .L3 gcc-13.1.0 -O1 eliminates the call to foo: j: movl $d, %eax ret main: movl $0, %eax call j movq %rax, i(%rip) movq %rax, k(%rip) movl $0, h(%rip) movl $0, %eax ret Bisects to r14-1880-g827e208fa64