https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108359
Bug ID: 108359 Summary: Dead Code Elimination Regression at -Os (trunk vs. 12.2.0) 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 54234 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54234&action=edit presented code as file cat case.c #864 int b = 10; int c; char e; void foo(); static char(a)(char f, char g) { return f && g == 1 ? 0 : f % g; } short(d)(short f, short g) { return f * g; } int main() { short h; int i; unsigned j; h = d(b && c, 5); j = h; i = a(h, 237); unsigned k = i; e = i < 0 || k >= 32 ? 0 : i >> k; if (e) { c = 0; foo(); } } `gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -Os` can not eliminate `foo` but `gcc-releases/gcc-12.2.0 -Os` can. `gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -Os -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB2: .cfi_startproc movl b(%rip), %eax testl %eax, %eax je .L3 xorl %eax, %eax cmpl $0, c(%rip) setne %al .L3: movb $5, %dl imull %edx, %eax movsbl %al, %edx movl %eax, %ecx sarl %cl, %edx movb %dl, e(%rip) testl %edx, %edx je .L12 pushq %rax .cfi_def_cfa_offset 16 xorl %edx, %edx xorl %eax, %eax movl %edx, c(%rip) call foo xorl %eax, %eax popq %rcx .cfi_def_cfa_offset 8 ret .L12: xorl %eax, %eax ret ---------- END OUTPUT --------- `gcc-releases/gcc-12.2.0 -Os -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB2: .cfi_startproc movb $0, e(%rip) xorl %eax, %eax ret ---------- END OUTPUT --------- Bisects to: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=9991d84d2a84355fd3fc9afc89a963f45991bfa9