| Issue |
63330
|
| Summary |
Dead Code Elimination Regression when using __builtin_unreachable (trunk vs 15)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
thetheodor
|
https://godbolt.org/z/EffzqnYq1
Given the following code:
```C
void foo(void);
static int a = 24821, d;
static int *b = &a;
static int **c = &b;
void __assert_fail();
static int *e(short f, short g) {
char h;
if (f) {
if (!(((g) >= 24821) && ((g) <= 24821))) {
__builtin_unreachable();
}
int *i = &d;
unsigned char j = g, k = f;
h = j % k;
if (h) i = 0;
if (b)
;
else
__assert_fail();
if (b || i)
;
else
foo();
;
}
return 0;
}
int main() { *c = e(a, a); }
```
clang-trunk -O2 generates:
```asm
main: # @main
# %bb.0:
pushq %rbx
movl a(%rip), %ebx
testw %bx, %bx
je .LBB0_5
# %bb.1:
cmpq $0, b(%rip)
jne .LBB0_5
# %bb.2:
xorl %eax, %eax
callq __assert_fail@PLT
cmpb $-11, %bl
je .LBB0_5
# %bb.3:
cmpq $0, b(%rip)
jne .LBB0_5
# %bb.4:
callq foo@PLT
.LBB0_5:
movq $0, b(%rip)
xorl %eax, %eax
popq %rbx
retq
.Lfunc_end0:
```
clang-15.0.7 -O2 generates:
```asm
main: # @main
# %bb.0:
pushq %rax
cmpw $0, a(%rip)
je .LBB0_3
# %bb.1:
cmpq $0, b(%rip)
jne .LBB0_3
# %bb.2:
xorl %eax, %eax
callq __assert_fail@PLT
.LBB0_3:
movq $0, b(%rip)
xorl %eax, %eax
popq %rcx
retq
.Lfunc_end0:
```
Bisects to 66efb986322b206834e7c9e1eb777fa053912c39 (@LebedevRI)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs