| Issue |
63798
|
| Summary |
Dead Code Elimination Regression (trunk vs 16)
|
| Labels |
|
| Assignees |
|
| Reporter |
thetheodor
|
https://godbolt.org/z/esv1zKddc
Given the following code:
```C
void foo(void);
static int a = 5;
static int **c, **d;
static int *e = &a;
static int **f = &e;
static int ***g = &c;
static short(h)(short b) {
if (!(((b) >= 1) && ((b) <= 1))) {
__builtin_unreachable();
}
return 0;
}
static void i(int **) {}
static int **k(int **j) {
*j = 0;
h(0);
return *g;
}
int main() {
int **l;
if (a)
;
else {
int *m;
f = &m;
d = &e;
l = k(d);
i(l);
if (e == 0)
;
else
foo();
;
}
h(0 <= 9);
}
```
clang-trunk -O3 does not eliminate the call to foo:
```asm
main: # @main
# %bb.0:
cmpl $0, a(%rip)
je .LBB0_1
# %bb.4:
xorl %eax, %eax
retq
.LBB0_1:
pushq %rax
movq %rsp, %rax
movq %rax, f(%rip)
cmpq $0, e(%rip)
je .LBB0_3
# %bb.2:
callq foo@PLT
.LBB0_3:
addq $8, %rsp
xorl %eax, %eax
retq
.Lfunc_end0:
```
clang-16.0.6 -O3 eliminates the call to foo:
```asm
main: # @main
# %bb.0:
xorl %eax, %eax
retq
.Lfunc_end0:
```
Bisects to 7739be7c6b6d017bf6b4445c5010e59314655995 (@jrbyrnes)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs