https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102703
Bug ID: 102703 Summary: [12 Regression] Dead Code Elimination Regression at -O3 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 void foo(void); static int a, b; static short c; int main() { for (; a; ++a) { unsigned short d = a; c = d >= 2 ? 0 : 2; if (!(b | d) && d) foo(); } } gcc-11.2.0 test.c -S -O3 -o /dev/stdout main: .LFB0: .cfi_startproc .L2: movl a(%rip), %eax testl %eax, %eax je .L12 incl a(%rip) jmp .L2 .L12: ret .cfi_endproc gcc-trunk test.c -S -O3 -o /dev/stdout main: .LFB0: .cfi_startproc movl a(%rip), %eax testl %eax, %eax je .L25 .p2align 4,,10 .p2align 3 .L24: movzwl %ax, %edx cmpw $1, %ax jbe .L27 testl %edx, %edx jne .L35 .L33: subq $8, %rsp .cfi_def_cfa_offset 16 .L4: call foo movl a(%rip), %eax addl $1, %eax movl %eax, a(%rip) je .L36 .L2: movzwl %ax, %edx cmpw $1, %ax jbe .L3 testl %edx, %edx je .L4 addl $1, %eax movl %eax, a(%rip) jne .L2 .L36: xorl %eax, %eax popq %rdx .cfi_def_cfa_offset 8 ret .p2align 4,,10 .p2align 3 .L35: addl $1, %eax movl %eax, a(%rip) jne .L24 .L25: xorl %eax, %eax ret .p2align 4,,10 .p2align 3 .L27: testl %edx, %edx jne .L30 testb $1, %al jne .L33 .L30: addl $1, %eax movl %eax, a(%rip) jmp .L24 .p2align 4,,10 .p2align 3 .L3: .cfi_def_cfa_offset 16 testl %edx, %edx jne .L6 testb $1, %al jne .L4 .L6: addl $1, %eax movl %eax, a(%rip) jmp .L2 .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 20211012 (experimental) (GCC) Started with https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=2e96b5f14e4025691b57d2301d71aa6092ed44bc (same as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102546)