https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110131
Bug ID: 110131 Summary: [13/14 Regression] Missed Dead Code Elimination when using __builtin_unreachable since r12-6924-gc2b610e7c6c 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/xr8Ka91rr Given: void foo(void); static int a, d, g, m, *h = &a, *i = &a; static char j, l, *n = &j; static short k; static short o(short b, short c) { return c == 0 || b && c == 1 ?: b / c; } static char p(unsigned char e, char f) { if (!(((e) >= 1) && ((e) <= 255))) { __builtin_unreachable(); } return e + f; } int main() { g = *h; *n = 0; int q = *i; l = p((k >= 0 ^ q >= k) - 1, 3); if (o(l >= j, g) + (unsigned)4294967291) o(0, d); else foo(); p(&m != 0, 0); } gcc-11.4 -O2 generates: main: movb $0, j(%rip) xorl %eax, %eax ret but gcc-trunk -O2 generates: main: movl a(%rip), %eax movb $0, j(%rip) cmpw $1, %ax ja .L8 .L4: xorl %eax, %eax ret .L8: cwtl leal 1(%rax), %edx cmpl $2, %edx movl $0, %edx cmova %edx, %eax cmpl $5, %eax jne .L4 pushq %rax call foo xorl %eax, %eax popq %rdx ret (12 and 13 generate similar code) Started with r12-6924-gc2b610e7c6c