https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108368
Bug ID: 108368 Summary: [13 Regression] Dead Code Elimination Regression at -O3 since r13-1759-gdbb093f4f15 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: yann at ywg dot ch Target Milestone: --- Created attachment 54244 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54244&action=edit Case file cat case.c #1409 int a; int b; short c; static int d = 4; void foo(); void e(int f) {} int main() { unsigned g = -27; for (; g > 7; ++g) { e(c && g); b ? 0 : a; if (g) { if (0 >= d) foo(); } else d = 0; } } `gcc-f99d7d669eaa2830eb5878df4da67e77ec791522 (trunk) -O3` can not eliminate `foo` but `gcc-releases/gcc-12.2.0 -O3` can. `gcc-f99d7d669eaa2830eb5878df4da67e77ec791522 (trunk) -O3 -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB1: .cfi_startproc pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movl $27, %ebx .L5: movl d(%rip), %eax testl %eax, %eax jle .L8 .L4: xorl %eax, %eax popq %rbx .cfi_remember_state .cfi_def_cfa_offset 8 ret .p2align 4,,10 .p2align 3 .L8: .cfi_restore_state xorl %eax, %eax call foo subl $1, %ebx jne .L5 jmp .L4 ---------- END OUTPUT --------- `gcc-releases/gcc-12.2.0 -O3 -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB1: .cfi_startproc xorl %eax, %eax ret ---------- END OUTPUT --------- Bisects to: r13-1759-gdbb093f4f15 commit dbb093f4f15ea66f2ce5cd2dc1903a6894563356 Author: Andrew MacLeod <amacl...@redhat.com> Date: Mon Jul 18 15:04:23 2022 -0400 Resolve complicated join nodes in range_from_dom. Join nodes which carry outgoing ranges on incoming edges are uncommon, but can still be resolved by setting the dominator range, and then calculating incoming edges. Avoid doing so if one of the incoing edges is not dominated by the same dominator. * gimple-range-cache.cc (ranger_cache::range_from_dom): Check for incoming ranges on join nodes and add to worklist.