https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114774
Bug ID: 114774 Summary: Missed DSE in simple code Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- In the following #include <stdio.h> int a; short *p; void test (int b) { a=1; if (b) { (*p)++; a=2; printf ("1\n"); } else { (*p)++; a=3; printf ("2\n"); } } We are not able to optimize out "a=1". This is simplified real-world scenario where SRA does not remove definition of SRAed variables. Note that clang does conditional move here test: # @test .cfi_startproc # %bb.0: movq p(%rip), %rax incw (%rax) xorl %eax, %eax testl %edi, %edi leaq .Lstr(%rip), %rcx leaq .Lstr.2(%rip), %rdi cmoveq %rcx, %rdi sete %al orl $2, %eax movl %eax, a(%rip) jmp puts@PLT # TAILCALL