Issue 63329
Summary Dead Code Elimination Regression when using __builtin_unreachable (trunk vs 16)
Labels new issue
Assignees
Reporter thetheodor
    https://godbolt.org/z/4b8f9zWc1

Given the following code:

```C
void foo(void);
static int a, c, f;
static int *g = &a, *k = &a;
static int **h = &g, **i = &g;
static short j = 65535, l;
static char m;
static char(n)(char b) {
    if (!(((b) >= -55) && ((b) <= 1))) {
 __builtin_unreachable();
    }
    return 0;
}
static short(o)(short d, short e) { return d + e; }
static char p() {
 n(1);
    n(201);
    **i;
    *h = &f;
    if (*k) return c;
 m = 12 - j;
    if (m)
        ;
    else
        foo();
 return l;
}
int main() {
    p();
    n(j);
    j = 0;
 for (; j <= 3; j = o(j, 4))
        ;
}

```
clang-trunk -O2 produces:

```asm
main:                                   # @main
# %bb.0:
	movzbl	j(%rip), %eax
	decb	%al
	orb	$4, %al
	cmpb	$12, %al
	jne	.LBB0_2
# %bb.1:
	pushq	%rax
	callq	foo@PLT
	addq	$8, %rsp
.LBB0_2:
	movb	$1, j(%rip)
	xorl	%eax, %eax
	retq
.Lfunc_end0:
```

clang-16.0.5 -O2 produces:

```asm
main:                                   # @main
# %bb.0:
	movb	$1, j(%rip)
	xorl	%eax, %eax
	retq
.Lfunc_end0:
```

Bisects to 84bcfa0e1b34938d1d11a44e9e17c6e222dd2f42 (@weiguozhi )
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to