https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110540
Bug ID: 110540
Summary: [14 Regression] Dead Code Elimination Regression since
r14-1163-gd8b058d3ca4
Product: gcc
Version: 14.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: ---
https://godbolt.org/z/WP14EKx7M
Given the following code:
void foo(void);
static int a = 1;
static int *d = &a;
static int **f = &d;
static int ***g = &f;
static char(h)(char b, char c) { return b - c; }
static char(i)(int e) {
if (!(((e) >= 1) && ((e) <= 254))) {
__builtin_unreachable();
}
return 0;
}
int main() {
char j = 0;
for (; j != -9; j = h(j, 9)) {
i(1);
*d = a ^ 255;
if (i(a) >= **f) **f = 0;
}
if (**g)
;
else
foo();
;
}
gcc-trunk -O2 does not eliminate the call to foo:
main:
movl a(%rip), %eax
movq f(%rip), %rdx
movq d(%rip), %rcx
xorb $-1, %al
movl %eax, (%rcx)
movq (%rdx), %rax
movl (%rax), %ecx
testl %ecx, %ecx
jle .L8
.L4:
xorl %eax, %eax
ret
.p2align 4,,10
.p2align 3
.L8:
cmpq $0, (%rdx)
movl $0, (%rax)
jne .L4
pushq %rax
call foo
xorl %eax, %eax
popq %rdx
ret
gcc-13.1.0 -O2 eliminates the call to foo:
main:
movl a(%rip), %eax
movq d(%rip), %rdx
xorb $-1, %al
movl %eax, (%rdx)
movq f(%rip), %rax
movq (%rax), %rax
movl (%rax), %ecx
testl %ecx, %ecx
jg .L2
xorl %edx, %edx
movl %edx, (%rax)
.L2:
xorl %eax, %eax
ret
Bisects to r14-1163-gd8b058d3ca4