[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


================
@@ -165,12 +165,75 @@ define void @store_texture2d_scalarized(float %x, float %y, float %z, float %w,
   %vec.3 = insertelement <4 x float> %vec.2, float %w, i32 3
 
   ; CHECK-NOT: insertelement
-  ; CHECK: %[[COORD0:.*]] = extractelement <2 x i32> %coords, i64 0
-  ; CHECK: %[[COORD1:.*]] = extractelement <2 x i32> %coords, i64 1
+  ; CHECK: %[[COORD0:.*]] = extractelement <2 x i32> %coords, i32 0
+  ; CHECK: %[[COORD1:.*]] = extractelement <2 x i32> %coords, i32 1
   ; CHECK: call void @dx.op.textureStore.f32(i32 67, %dx.types.Handle %{{.*}}, i32 %[[COORD0]], i32 %[[COORD1]], i32 undef, float %x, float %y, float %z, float %w, i8 15)
   call void @llvm.dx.resource.store.texture(
       target("dx.Texture", <4 x float>, 1, 0, 0, 2) %texture,
       <2 x i32> %coords, <4 x float> %vec.3)
 
   ret void
 }
+
+; DXIL has no vector instructions, so the scalars the coordinate vector was
+; built from are forwarded into the store rather than extracted again.
+; CHECK-LABEL: define void @store_texture2darray_scalarized_coords(
+define void @store_texture2darray_scalarized_coords(float %data, i32 %x, i32 %y, i32 %z) {
+  %texture = call target("dx.Texture", float, 1, 0, 0, 7)
+      @llvm.dx.resource.handlefrombinding(i32 0, i32 9, i32 1, i32 0, ptr null)
+
+  %coords.0 = insertelement <3 x i32> poison, i32 %x, i32 0
+  %coords.1 = insertelement <3 x i32> %coords.0, i32 %y, i32 1
+  %coords.2 = insertelement <3 x i32> %coords.1, i32 %z, i32 2
+
+  ; CHECK-NOT: insertelement
+  ; CHECK-NOT: extractelement
+  ; CHECK: call void @dx.op.textureStore.f32(i32 67, %dx.types.Handle %{{.*}}, i32 %x, i32 %y, i32 %z, float %data, float %data, float %data, float %data, i8 15)
+  call void @llvm.dx.resource.store.texture(
+      target("dx.Texture", float, 1, 0, 0, 7) %texture,
+      <3 x i32> %coords.2, float %data)
+
+  ; CHECK-NOT: insertelement
----------------
bob80905 wrote:

This is a redundant check-not, you have one on line 189

https://github.com/llvm/llvm-project/pull/223091


More information about the llvm-commits mailing list