[llvm] [DirectX] Make DXILOpLowering split vector coordinates, offsets, and gradient operands (PR #223091)
Joshua Batista via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 15:48:23 PDT 2026
================
@@ -336,3 +336,46 @@ define void @samplegrad_texture2d_half4(<2 x float> %coords, <2 x float> %ddx, <
call void @use_half4(<4 x half> %data)
ret void
}
+
+; DXIL has no vector instructions, so the scalars the vector operands were
+; built from are forwarded into the sample rather than extracted again.
+; CHECK-LABEL: define void @sample_grad_texture2d_scalarized(
+define void @sample_grad_texture2d_scalarized(float %u, float %v, float %ddxu,
+ float %ddxv, float %ddyu,
+ float %ddyv) {
+ %texture = call target("dx.Texture", <4 x float>, 0, 0, 0, 2)
+ @llvm.dx.resource.handlefrombinding.tdx.Texture_v4f32_0_0_0_2t(
+ i32 0, i32 0, i32 1, i32 0, ptr null)
+ %sampler = call target("dx.Sampler", 0)
+ @llvm.dx.resource.handlefrombinding.tdx.Sampler_0t(
+ i32 0, i32 0, i32 1, i32 0, ptr null)
+
+ %coords.0 = insertelement <2 x float> poison, float %u, i32 0
+ %coords.1 = insertelement <2 x float> %coords.0, float %v, i32 1
+ %ddx.0 = insertelement <2 x float> poison, float %ddxu, i32 0
+ %ddx.1 = insertelement <2 x float> %ddx.0, float %ddxv, i32 1
+ %ddy.0 = insertelement <2 x float> poison, float %ddyu, i32 0
+ %ddy.1 = insertelement <2 x float> %ddy.0, float %ddyv, i32 1
+
+ ; CHECK-NOT: insertelement
+ ; CHECK-NOT: extractelement <2 x float>
----------------
bob80905 wrote:
Can this be reduced and the 2 x float dropped?
https://github.com/llvm/llvm-project/pull/223091
More information about the llvm-commits
mailing list