[llvm] [DirectX] Introduce the DXILResourceAccess pass (PR #116726)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 22 00:58:31 PST 2024
================
@@ -0,0 +1,35 @@
+; RUN: opt -S -dxil-resource-access %s | FileCheck %s
+
+target triple = "dxil-pc-shadermodel6.6-compute"
+
+declare void @use_float4(<4 x float>)
+declare void @use_float(<4 x float>)
+
+; CHECK-LABEL: define void @load_float4
+define void @load_float4(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)
+
+ ; CHECK: %[[VALUE:.*]] = 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)
+ %vec_data = load <4 x float>, ptr %ptr
+ call void @use_float4(<4 x float> %vec_data)
+
+ ; CHECK: %[[VALUE:.*]] = 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: extractelement <4 x float> %[[VALUE]], i32 4
+ %y_ptr = getelementptr inbounds <4 x float>, ptr %ptr, i32 0, i32 4
----------------
bogner wrote:
The "y" element, this was a typo.
https://github.com/llvm/llvm-project/pull/116726
More information about the llvm-commits
mailing list