<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/136780>136780</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SPIRV] Pointer legalization fails due to unimplemented downcasts
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
winocm
</td>
</tr>
</table>
<pre>
It looks like the pointer legalization bitcast pass fails horrifically if there is a GEP instruction used before that does not end up feeding into the actual load. Stores also similarly fail.
Here is a minimal test case reproducing this issue:
```
%struct.Uniforms = type { %struct.Matrix, %struct.Matrix }
%struct.Matrix = type { [4 x <4 x float>] }
define void @foo(ptr addrspace(2) %0) {
%2 = getelementptr inbounds %struct.Uniforms, ptr addrspace(2) %0, i64 0, i32 0, i32 0, i64 10
%3 = load volatile <4 x float>, ptr addrspace(2) %0, align 16
ret void
}
define void @foo2(ptr addrspace(2) %0) {
%2 = getelementptr inbounds %struct.Uniforms, ptr addrspace(2) %0, i64 0, i32 0, i32 0, i64 10
store volatile <4 x float> splat (float 0.0), ptr addrspace(2) %0, align 16
ret void
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVE1v6zYQ_DXUZfEMmvqyDjrY8XP7DgWCBu2dElfyNhQpkCun7q8vKDtN0zTtoZcaBkittDuzQ-7oGGl0iK0oD6I8Znrhsw_tCznfT1nnzbX9xmC9f45g6RmBzwizJ8cYwOKoLf2mmbyDjrjXkWHWMcKgyUY4-xBooF5bewUaUm5AoAgavvv6COQih6Vfs5eIBjocfEgQmsF4jOA8AzoDywwDoiE3Ajn2Kwnd86ItWK_NBp7YB4ygbfQQaSKrg72uLDZC7oXcf_8H8kSOJm2BMTL0OiIEnIM3S5_K85kiUIwLinx_SxWVvP_lXqjyxnnzk6PBhymCyI_A1xlB1Ad4e_-D5kC_CvXwIQaiPr4r9Rp-V6g8FJBiD2kZrNcs8q-iPL5my73BgRzCxZMBUcjBe6F2MwfQxoQ46x6F2imhmsRArmt9EHIP6VmtcCMyWpzQccoj1_nFmQgfu0x9_EPpB6CqgNsmV3_dVAVsk3jp43zFTYcGF281k8UPTf4blrY0OthWay8BeZUgafK5Mur_Lk1MF_hTSSDOVjMItVsjIDeJ9H8V6k_3OjNtbpq80Rm227oo80o2dZWd26qT5YC67Lqu6IqiGfJtL8uq0TjU2y32GbVKqlIWKv2avNrUujO7qqmHqm6avK9FIXFKg2jtZdr4MGbreLXbvKp3MrO6QxtX-1HK4ct9-JRKbhTalPSlW8YoCmkpcnwrw8R29a2nx28__pxG4_HvfOlmRWZBYA-Lo2m-HSsaMP7FJc-K2RJse2aeY5p6dRLqNBKfl27T-0moU8K8L1_m4H_BnoU6rUyjUKd7K5dW_R4AAP__OsWlSg">