Issue 124928
Summary [SPIR-V] Non-logical pointer generated following an ptrcast
Labels SPIR-V
Assignees Keenuts
Reporter Keenuts
    Logical SPIR-V is not allowing pointer cast after an `OpAccessChain`.

Given this LLVM IR:
```llvm
define internal spir_func void @baz(ptr addrspace(10) %a, i64 %b) {
  %index = getelementptr <4 x i32>, ptr addrspace(10) %a, i64 %b
 %load = load <3 x i32>, ptr addrspace(10) %index, align 4
  ret void
}
```

In OpenCL SPIR-V, the following instructions would be generated:

```
    %index_1 = OpAccessChain %_ptr_Private_v4uint %a_1
 %28 = OpBitcast %_ptr_Private_v3uint %index_1
    %loadv_1 = OpLoad %v3uint %28 Aligned 4
```

This is not allowed in logical SPIR-V.

For this specific case, what we'd need is to load the initial `<4 x i32>`, then `OpCompositeExtract` and then `OpCompositeConstruct`.

If the types were of the same bit-size, we could to the `OpBitcast`, but on the value after the load.
For other types of cast, we might have to handle this differently (loading the initial member of a struct for ex).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to