<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64114>64114</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crash in InstCombine after and/or const expressions marked undesirable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ormris
</td>
</tr>
</table>
<pre>
@nikic We bisected the crash to 0cab8d20417c0e2ccc1ffc5505e080126f5de8e6. Steps to reproduce below.
```
$ cat test.ll
target triple = "aarch64-none-linux"
%struct.e = type { %struct.anon.16, %struct.f }
%struct.anon.16 = type { ptr }
%struct.f = type { %struct.d, i32 }
%struct.d = type { ptr, i32, i32, ptr }
@g = external global i32
define void @a(ptr %ident) {
entry:
tail call void @b(ptr %ident)
ret void
}
define void @b(ptr %wchan) {
entry:
%0 = ptrtoint ptr %wchan to i32
%shr = lshr i32 %0, 8
%xor = xor i32 %shr, %0
%and = and i32 %xor, 1
%h = getelementptr [256 x %struct.e], ptr null, i32 0, i32 %and, i32 1, i32 1
%1 = load volatile i32, ptr %h, align 4
ret void
}
define void @c() {
entry:
tail call void @a(ptr @g)
ret void
}
$ opt -O2 -o opt.ll test.ll
Assertion failed: isa<To>(Val) && "cast<Ty>() argument of incompatible type!", file C:\llvm-project\llvm\include\llvm/Support/Casting.h, line 578
...
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVcuO47YS_Rp6U2iBol72Qose-xq4qywmSNYUWZKYoUmBLPW4_z4gre62eyZBEkAQX6dep44oGaOZHGLPmi-sOe3kSrMPvQ-XYOJu8Pq1ZzV35ptR8DvCYCIqQg00I6gg4wzkgSs57LXgddkpjkIpVY6jahreIN_zUrRjo3GPbQFfCZeYTAIuwetVIQxo_feC8RPjz9u75dtzW4oalCQgjFRYe9skGSYkoGAWi8CqEzAhpAxqbusn5x0-WePWKxPiwbNoIoVVU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