https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110538
Bug ID: 110538
Summary: [14 Regression] Dead Code Elimination Regression since
r14-368-ge1366a7e4ce
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/53Ys78do1
Given the following code:
void foo(void);
static int b, d, f;
static int *c, *e = &d;
static unsigned g;
void a();
int main() {
g = -19;
for (; g; ++g) {
int h = g;
int *i = &b;
int **j = &i;
if (d) {
int **k = &i;
j = &c;
*k = &f;
} else
*e = 0;
if (!(((h) >= -19) && ((h) <= -1))) {
__builtin_unreachable();
}
if (i)
;
else
a();
if (j == &i || j == &c)
;
else
foo();
;
}
}
gcc-trunk -O2 does not eliminate the call to foo:
main:
subq $24, %rsp
movl $-19, g(%rip)
.p2align 4,,10
.p2align 3
.L4:
movl d(%rip), %edx
movl $c, %eax
testl %edx, %edx
jne .L2
leaq 8(%rsp), %rax
.L2:
cmpq $c, %rax
je .L5
leaq 8(%rsp), %rdx
cmpq %rdx, %rax
je .L5
call foo
.L5:
addl $1, g(%rip)
jne .L4
xorl %eax, %eax
addq $24, %rsp
ret
gcc-13.1.0 -O2 eliminates the call to foo:
main:
movl $-19, g(%rip)
.p2align 4,,10
.p2align 3
.L2:
movl g(%rip), %eax
addl $1, %eax
movl %eax, g(%rip)
jne .L2
ret
Bisects to r14-368-ge1366a7e4ce