https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111864
Bug ID: 111864
Summary: [14 Regression] Dead Code Elimination Regression since
r14-4038-gb975c0dc3be
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/PoYvWMG7T
Given the following code:
void foo(void);
static int d, g = 4, k;
static int *h, *j, *s;
static int **i = &h, **t = &s;
static int ***l = &i;
static unsigned short *m, *n;
static unsigned short **o = &n, **u = &m;
void __assert_fail() __attribute__((__noreturn__));
static short(a)(short b, int c) { return b << c; }
static int(e)(int f) {
if (!(((f) >= 0) && ((f) <= 0))) {
__builtin_unreachable();
}
return d;
}
static int ***p(int **q) {
j = *q;
return &i;
}
static int *r() {
short v = a((g && p(t)) <= 0, 5);
e(v);
if (s) o = u;
if (o == &m || o == &n)
;
else
__assert_fail();
return &k;
}
int main() {
**l = r();
if (h)
;
else
__assert_fail();
if (j == &g == 0)
;
else
__assert_fail();
if (o == &m || o == &n)
;
else
foo();
;
}
gcc-trunk -O2 does not eliminate the call to foo:
main:
subq $8, %rsp
movq s(%rip), %rax
movq i(%rip), %rdx
movq %rax, j(%rip)
testq %rax, %rax
je .L17
movq $k, (%rdx)
cmpq $0, h(%rip)
movq $m, o(%rip)
je .L5
cmpq $g, %rax
je .L5
movl $m, %eax
.L10:
cmpq $n, %rax
je .L12
cmpq $m, %rax
je .L12
call foo
.L12:
xorl %eax, %eax
addq $8, %rsp
ret
.L17:
movq o(%rip), %rax
cmpq $m, %rax
je .L18
cmpq $n, %rax
jne .L5
movq $k, (%rdx)
cmpq $0, h(%rip)
jne .L10
.L5:
xorl %eax, %eax
call __assert_fail
.L18:
movq $k, (%rdx)
cmpq $0, h(%rip)
jne .L12
jmp .L5
gcc-13.2.0 -O2 eliminates the call to foo:
main:
movq s(%rip), %rax
movq i(%rip), %rdx
movq %rax, j(%rip)
testq %rax, %rax
je .L2
movq $k, (%rdx)
cmpq $0, h(%rip)
movq $m, o(%rip)
je .L4
cmpq $g, %rax
je .L4
.L8:
xorl %eax, %eax
ret
.L2:
movq o(%rip), %rax
cmpq $m, %rax
je .L5
cmpq $n, %rax
jne .L4
.L5:
movq $k, (%rdx)
cmpq $0, h(%rip)
jne .L8
.L4:
pushq %rax
xorl %eax, %eax
call __assert_fail
Bisects to r14-4038-gb975c0dc3be