https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111013
Bug ID: 111013 Summary: [14 Regression] Dead Code Elimination Regression at -O2 since r14-338-g1dd154f6407 Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: scherrer.sv at gmail dot com Target Milestone: --- static int b, c, e; static unsigned d; static short f; void foo(void); void(a)(); static char g(int h) { int i = 2749857453; j: a(); k: if (b) goto j; f = 1; if ((unsigned)(7 ^ e | (h & d && f)) >= 2) i = 0; e = 0; if (c) goto k; if (!(i <= 6)) foo(); return h; } int main() { d--; b = c = e && g(1); } gcc-9ec5d6de735 (trunk) -O2 cannot eliminate the call to foo but gcc-releases/gcc-13.1.0 -O2 can. ----------------------------------------------------------------------- gcc-9ec5d6de7355c15b3811150d1581dab5bd489966 -O2 case.c -S -o case.s --------- OUTPUT --------- main: .LFB1: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 movl e(%rip), %eax subl $1, d(%rip) testl %eax, %eax jne .L3 .L2: movl %eax, c(%rip) movl %eax, b(%rip) xorl %eax, %eax addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .p2align 4,,10 .p2align 3 .L3: .cfi_restore_state xorl %eax, %eax call a movl b(%rip), %edx testl %edx, %edx jne .L3 movl d(%rip), %ecx movl e(%rip), %eax movl $-1545109843, %edx xorl %esi, %esi movl c(%rip), %edi andl $1, %ecx jmp .L5 .p2align 4,,10 .p2align 3 .L8: xorl %eax, %eax .L5: xorl $7, %eax orl %ecx, %eax cmpl $2, %eax cmovnb %esi, %edx testl %edi, %edi jne .L8 xorl %eax, %eax movl %eax, e(%rip) cmpl $6, %edx jg .L15 .L6: movl $1, %eax jmp .L2 .L15: call foo jmp .L6 ---------- END OUTPUT --------- ----------------------------------------------------------------------- gcc-2b98cc24d6af0432a74f6dad1c722ce21c1f7458 -O2 case.c -S -o case.s --------- OUTPUT --------- main: .LFB1: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 movl e(%rip), %eax subl $1, d(%rip) testl %eax, %eax jne .L3 .L2: movl %eax, c(%rip) movl %eax, b(%rip) xorl %eax, %eax addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .p2align 4,,10 .p2align 3 .L3: .cfi_restore_state xorl %eax, %eax call a movl b(%rip), %edx movl c(%rip), %eax testl %edx, %edx jne .L3 testl %eax, %eax je .L4 .L5: jmp .L5 .L4: xorl %eax, %eax movl %eax, e(%rip) movl $1, %eax jmp .L2 ---------- END OUTPUT --------- ----------------------------------------------------------------------- Bisects to r14-338-g1dd154f6407