[llvm] [DirectX] add GEP i8 legalization (PR #142475)
Deric C. via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 3 14:10:23 PDT 2025
Icohedron wrote:
> the bug I was looking at used allocsa, this one uses a globals its an easy fix to add:
>
> ```
> if (auto *GV = dyn_cast<GlobalVariable>(BasePtr))
> ElementType = GV->getValueType();
> ```
>
> However during my testing I found another gap. we still need to figure out how to support constExpr GEPs.
>
> > > This PR appears to fail to compile this shader: https://godbolt.org/z/9MPc8Wca5
> >
> >
> > This shader now compiles, but it currently fails DXIL validation
Incorporating that change still results in a shader that doesn't pass validation due to the same message: `Explicit gep operator type does not match pointee type of pointer operand`
The DXIL Legalize pass now emits:
```llvm
@g = local_unnamed_addr addrspace(3) global [2 x float] zeroinitializer, align 4
...
define void @CSMain() local_unnamed_addr #0 {
entry:
...
%2 = load float, ptr addrspace(3) getelementptr inbounds nuw (float, ptr addrspace(3) @g, i32 1), align 4
```
I would expect the `%2` instruction to be the following to be a valid GEP:
```llvm
%2 = load float, ptr addrspace(3) getelementptr inbounds nuw ([2 x float], ptr addrspace(3) @g, i32 0, i32 1), align 4
```
This doesn't seem to be something straightforward to fix.
https://github.com/llvm/llvm-project/pull/142475
More information about the llvm-commits
mailing list