https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108352
Bug ID: 108352 Summary: Dead Code Elimination Regression at -O2 (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 54227 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54227&action=edit Code as file cat case.c #30 long a; int b; void bar64_(void); void foo(); int main() { char c = 0; unsigned d = 10; int e = 2; for (; d; d--) { bar64_(); b = d; e && (c = (e = 0) != 4) > 1; } if (c < 1) foo(); a = b; } `gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2` can not eliminate `foo` but `gcc-releases/gcc-12.2.0 -O2` can. `gcc-cb93c5f8008b95743b741d6f1842f9be50c6985c (trunk) -O2 -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB0: .cfi_startproc pushq %r13 .cfi_def_cfa_offset 16 .cfi_offset 13, -16 movl $1, %r13d pushq %r12 .cfi_def_cfa_offset 24 .cfi_offset 12, -24 movl $2, %r12d pushq %rbp .cfi_def_cfa_offset 32 .cfi_offset 6, -32 xorl %ebp, %ebp pushq %rbx .cfi_def_cfa_offset 40 .cfi_offset 3, -40 movl $10, %ebx subq $8, %rsp .cfi_def_cfa_offset 48 .p2align 4,,10 .p2align 3 .L3: call bar64_ testl %r12d, %r12d movl %ebx, b(%rip) cmovne %r13d, %ebp xorl %r12d, %r12d subl $1, %ebx jne .L3 movl $1, %eax testb %bpl, %bpl je .L10 .L4: movq %rax, a(%rip) addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 40 xorl %eax, %eax popq %rbx .cfi_def_cfa_offset 32 popq %rbp .cfi_def_cfa_offset 24 popq %r12 .cfi_def_cfa_offset 16 popq %r13 .cfi_def_cfa_offset 8 ret .L10: .cfi_restore_state xorl %eax, %eax call foo movslq b(%rip), %rax jmp .L4 ---------- END OUTPUT --------- `gcc-releases/gcc-12.2.0 -O2 -S -o /dev/stdout case.c` --------- OUTPUT --------- main: .LFB0: .cfi_startproc pushq %rbx .cfi_def_cfa_offset 16 .cfi_offset 3, -16 movl $10, %ebx call bar64_ movl $10, %eax jmp .L3 .p2align 4,,10 .p2align 3 .L6: call bar64_ movl %ebx, %eax .L3: movl %eax, b(%rip) subl $1, %ebx jne .L6 movq $1, a(%rip) xorl %eax, %eax popq %rbx .cfi_def_cfa_offset 8 ret ---------- END OUTPUT --------- Bisects to: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d86d81a449c03641e079f23a2b3e1b2279a162fe