[llvm] [DirectX] Introduce the DXILResourceAccess pass (PR #116726)
Helena Kotas via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 10:21:30 PST 2024
================
@@ -0,0 +1,103 @@
+; RUN: opt -S -dxil-resource-access %s | FileCheck %s
+
+target triple = "dxil-pc-shadermodel6.6-compute"
+
+; CHECK-LABEL: define void @store_float4
+define void @store_float4(<4 x float> %data, i32 %index, i32 %elemindex) {
+ %buffer = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
+ @llvm.dx.handle.fromBinding.tdx.TypedBuffer_v4f32_1_0_0(
+ i32 0, i32 0, i32 1, i32 0, i1 false)
+
+ ; CHECK-NOT: @llvm.dx.resource.getpointer
+ %ptr = call ptr @llvm.dx.resource.getpointer(
+ target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer, i32 %index)
+
+ ; Store the whole value
+ ; CHECK: call void @llvm.dx.typedBufferStore.tdx.TypedBuffer_v4f32_1_0_0t.v4f32(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer, i32 %index, <4 x float> %data)
+ store <4 x float> %data, ptr %ptr
+
+ ; Store just the .x component
+ %scalar = extractelement <4 x float> %data, i32 0
+ ; CHECK: %[[LOAD:.*]] = call <4 x float> @llvm.dx.typedBufferLoad.v4f32.tdx.TypedBuffer_v4f32_1_0_0t(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer, i32 %index)
+ ; CHECK: %[[INSERT:.*]] = insertelement <4 x float> %[[LOAD]], float %scalar, i32 0
+ ; CHECK: call void @llvm.dx.typedBufferStore.tdx.TypedBuffer_v4f32_1_0_0t.v4f32(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer, i32 %index, <4 x float> %[[INSERT]])
+ store float %scalar, ptr %ptr
+
+ ; Store just the .y component
+ ; CHECK: %[[LOAD:.*]] = call <4 x float> @llvm.dx.typedBufferLoad.v4f32.tdx.TypedBuffer_v4f32_1_0_0t(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer, i32 %index)
+ ; CHECK: %[[INSERT:.*]] = insertelement <4 x float> %[[LOAD]], float %scalar, i32 1
+ ; CHECK: call void @llvm.dx.typedBufferStore.tdx.TypedBuffer_v4f32_1_0_0t.v4f32(target("dx.TypedBuffer", <4 x float>, 1, 0, 0) %buffer, i32 %index, <4 x float> %[[INSERT]])
+ %y_ptr = getelementptr inbounds i8, ptr %ptr, i32 4
----------------
hekota wrote:
Other test cases have `getelementptr inbounds <4 x float>` and this one has `getelementptr inbounds i8`. Is that intentional?
https://github.com/llvm/llvm-project/pull/116726
More information about the llvm-commits
mailing list