-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
Description
DXILResourceAccess does not seem to calculate vector element offset correctly when translating llvm.dx.resource.getpointer & getelementptr & store for a single vector element store.
HLSL:
RWStructuredBuffer<uint4> Out : register(u1);
[numthreads(4, 4, 1)]
void main(uint3 ThreadID : SV_GroupThreadID) {
Out[0][ThreadID.y] = 111;
}
IR before DXILResourceAccess pass:
; RUN: opt -S -dxil-resource-access -mtriple dxilv1.5-unknown-shadermodel6.5-compute %s
target triple = "dxilv1.5-unknown-shadermodel6.5-compute"
define void @main() local_unnamed_addr {
entry:
%0 = tail call target("dx.RawBuffer", <4 x i32>, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_v4i32_1_0t(i32 0, i32 1, i32 1, i32 0, ptr null)
%1 = tail call i32 @llvm.dx.thread.id.in.group(i32 1)
%2 = tail call noundef nonnull align 16 dereferenceable(16) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_v4i32_1_0t(target("dx.RawBuffer", <4 x i32>, 1, 0) %0, i32 0)
%3 = getelementptr i32, ptr %2, i32 %1
store i32 111, ptr %3, align 4
ret void
}
IR after DXILResourceAccess pass:
define void @main() local_unnamed_addr {
entry:
%0 = tail call target("dx.RawBuffer", <4 x i32>, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_v4i32_1_0t(i32 0, i32 1, i32 1, i32 0, ptr null)
%1 = tail call i32 @llvm.dx.thread.id.in.group(i32 1)
call void @llvm.dx.resource.store.rawbuffer.tdx.RawBuffer_v4i32_1_0t.i32(target("dx.RawBuffer", <4 x i32>, 1, 0) %0, i32 0, i32 %1, i32 111)
ret void
}
The 3rd argument of llvm.dx.resource.store.rawbuffer is element offset and it should be multiplied by size of i32.
Related to #160208
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Active