[llvm] [DirectX] add GEP i8 legalization (PR #142475)
Deric C. via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 3 11:53:43 PDT 2025
Icohedron wrote:
> This PR appears to fail to compile this shader: https://godbolt.org/z/9MPc8Wca5
>
This shader now compiles, but it currently fails DXIL validation with the message
```
Explicit gep operator type does not match pointee type of pointer operand
Validation failed.
```
I think the i8 legalization is producing an incorrect GEP.
I see the pass converting these instructions:
```llvm
%2 = getelementptr inbounds nuw i8, ptr addrspace(3) @g, i32 4
%3 = load float, ptr addrspace(3) %2, align 4
```
into
```llvm
%2 = load float, ptr addrspace(3) getelementptr inbounds nuw (ptr addrspace(3), ptr addrspace(3) @g, i32 1), align 4
```
but I would have expected this instead:
```llvm
%2 = load float, ptr addrspace(3) getelementptr inbounds nuw ([2 x float], ptr addrspace(3) @g, i32 0, i32 1), align 4
```
because the global is defined as `@g = local_unnamed_addr addrspace(3) global [2 x float] zeroinitializer, align 4` and an earlier store operation in the IR looks fine
```llvm
%arrayidx.i = getelementptr inbounds nuw [2 x float], ptr addrspace(3) @g, i32 0, i32 %1
store float 0.000000e+00, ptr addrspace(3) %arrayidx.i, align 4, !tbaa !5
```
https://github.com/llvm/llvm-project/pull/142475
More information about the llvm-commits
mailing list