https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102895
Bug ID: 102895 Summary: [12 Regression] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0) Product: gcc Version: 12.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: --- cat test.c master static int a, b, c; void foo(void); int main() { for (a = 0; a <= 1; ++a) if (c <= a) { for (b = 0; b <= 1; ++b) ; } else foo(); } 11.2.0 at -O3 can eliminate the call to foo but trunk at -O3 cannot: gcc-11 -O3 -S test.c -o /dev/stdout ... main: .LFB0: .cfi_startproc xorl %eax, %eax .p2align 4,,10 .p2align 3 .L2: movl $2, b(%rip) addl $1, %eax movl %eax, a(%rip) cmpl $1, %eax je .L2 xorl %eax, %eax ret .cfi_endproc gcc-trunk -O3 -S test.c -o /dev/stdout ... main: .LFB0: .cfi_startproc subq $8, %rsp .cfi_def_cfa_offset 16 xorl %eax, %eax movl $0, a(%rip) .p2align 4,,10 .p2align 3 .L5: testl %eax, %eax jns .L9 call foo .p2align 4,,10 .p2align 3 .L7: movl a(%rip), %eax addl $1, %eax movl %eax, a(%rip) cmpl $1, %eax jle .L5 xorl %eax, %eax addq $8, %rsp .cfi_remember_state .cfi_def_cfa_offset 8 ret .p2align 4,,10 .p2align 3 .L9: .cfi_restore_state movl $2, b(%rip) jmp .L7 .cfi_endproc gcc-trunk -v Using built-in specs. Target: x86_64-pc-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.0.0 20211022 (experimental) (GCC) Introduced with https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d8e1f1d24179690fd9c0f63c27b12e030010d9ea