llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Finn Plummer (inbelic)

<details>
<summary>Changes</summary>

This pr updates the placeholder calls with their correctly computed operands. 
It also removes unused operands from the intrinsic.

Note: this doesn't account for a matrix type as the leaf type as this is 
blocked on a resolution to https://github.com/llvm/llvm-project/issues/211977. 
This is tracked separately.

Each call will be emit per register row, it is then the job of the scalarizer 
to ensure the element relative column is updated correctly. This means that 
this col will always be assigned 0 at codegen time.

Resolves #<!-- -->204876

Assisted by: Claude Opus 4.8 and GPT 5.6 Sol

---

Patch is 32.29 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/212656.diff


16 Files Affected:

- (modified) clang/lib/CodeGen/CGHLSLRuntime.cpp (+149-30) 
- (modified) clang/lib/CodeGen/CGHLSLRuntime.h (+8) 
- (modified) clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl (+2-2) 
- (modified) clang/test/CodeGenHLSL/semantics/SV_Position.vs.hlsl (+2-2) 
- (modified) clang/test/CodeGenHLSL/semantics/SV_Target.ps.hlsl (+1-1) 
- (modified) clang/test/CodeGenHLSL/semantics/SV_VertexID.vs.hlsl (+1-1) 
- (modified) clang/test/CodeGenHLSL/semantics/semantic.arbitrary.hlsl (+3-3) 
- (modified) clang/test/CodeGenHLSL/semantics/semantic.array.hlsl (+7-4) 
- (modified) clang/test/CodeGenHLSL/semantics/semantic.array.output.hlsl (+6-3) 
- (modified) 
clang/test/CodeGenHLSL/semantics/semantic.explicit-location-output-struct.hlsl 
(+1-1) 
- (modified) clang/test/CodeGenHLSL/semantics/semantic.explicit-location.hlsl 
(+1-1) 
- (added) clang/test/CodeGenHLSL/semantics/semantic.input.hlsl (+55) 
- (added) clang/test/CodeGenHLSL/semantics/semantic.output.hlsl (+58) 
- (modified) clang/test/CodeGenHLSL/semantics/semantic.struct.output.hlsl 
(+2-2) 
- (modified) clang/test/CodeGenHLSL/sret_output.hlsl (+1-1) 
- (modified) llvm/include/llvm/IR/IntrinsicsDirectX.td (+12-8) 


``````````diff
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 8794579166b6a..0ef1456fec49e 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -1142,21 +1142,59 @@ void CGHLSLRuntime::emitSPIRVUserSemanticStore(
                            VariableName.str());
 }
 
+namespace {
+// Describes how a semantic leaf lowers to signature rows
+struct SemanticShape {
+  unsigned Rows;
+  unsigned Cols;
+  QualType RowType;
+};
+} // namespace
+
+// Returns the QualType of a semantic leaf declarator. For a function the
+// declared return type is used, otherwise the declared type.
+static QualType getSemanticLeafType(const clang::DeclaratorDecl *Decl) {
+  if (const auto *FD = dyn_cast<clang::FunctionDecl>(Decl))
+    return FD->getDeclaredReturnType();
+  return Decl->getType();
+}
+
+// Walks through the surrounding constant array types of \p Ty, accumulating 
the
+// number of rows, until reaching a scalar, vector, or matrix leaf. The leaf is
+// returned as the row type together with the number of rows.
+static SemanticShape getSemanticShape(ASTContext &Ctx, QualType Ty) {
+  unsigned Rows = 1;
+  while (const ConstantArrayType *CAT = Ctx.getAsConstantArrayType(Ty)) {
+    Rows *= CAT->getSize().getZExtValue();
+    Ty = CAT->getElementType();
+  }
+
+  unsigned Cols = 1;
+  if (const auto *VT = Ty->getAs<clang::VectorType>()) {
+    Cols = VT->getNumElements();
+  } else if (const auto *MT = Ty->getAs<clang::ConstantMatrixType>()) {
+    // FIXME: a matrix leaf lowers to one row per matrix row but if 
column_major
+    // is specified we transpose the num rows and num cols, this depends on
+    // #211977 to resolve
+    Cols = MT->getNumColumns();
+  }
+
+  return {Rows, Cols, Ty};
+}
+
 llvm::Value *
 CGHLSLRuntime::emitDXILUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
+                                        const clang::DeclaratorDecl *Decl,
                                         HLSLAppliedSemanticAttr *Semantic,
                                         std::optional<unsigned> Index) {
-  Twine BaseName = Twine(Semantic->getAttrName()->getName());
-  Twine VariableName = BaseName.concat(Twine(Index.value_or(0)));
+  StringRef Name = Semantic->getAttrName()->getName();
+  SemanticShape Shape =
+      getSemanticShape(CGM.getContext(), getSemanticLeafType(Decl));
 
-  // DXIL packing rules etc shall be handled here.
-  // FIXME: generate proper sigpoint, index, col, row values.
-  // FIXME: also DXIL loads vectors element by element.
-  SmallVector<Value *> Args{B.getInt32(4), B.getInt32(0), B.getInt32(0),
-                            B.getInt8(0),
-                            llvm::PoisonValue::get(B.getInt32Ty())};
+  llvm::Type *RowTy = CGM.getTypes().ConvertTypeForMem(Shape.RowType);
 
-  llvm::Intrinsic::ID IntrinsicID = llvm::Intrinsic::dx_load_input;
+  llvm::Function *IntrFn = llvm::Intrinsic::getOrInsertDeclaration(
+      B.GetInsertBlock()->getModule(), llvm::Intrinsic::dx_load_input, 
{RowTy});
 
   SmallVector<OperandBundleDef, 1> OB;
   if (auto *Token = getConvergenceToken(*B.GetInsertBlock())) {
@@ -1164,26 +1202,82 @@ 
CGHLSLRuntime::emitDXILUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
     OB.emplace_back("convergencectrl", bundleArgs);
   }
 
-  llvm::Function *IntrFn = llvm::Intrinsic::getOrInsertDeclaration(
-      B.GetInsertBlock()->getModule(), IntrinsicID, {Type});
-  llvm::Value *Value = B.CreateCall(IntrFn, Args, OB, VariableName);
-  return Value;
+  unsigned SigId = DXILInputSemanticIndex++;
+  unsigned Row = 0;
+
+  // Scalar and vector leaves need no aggregate reconstruction.
+  if (!isa<llvm::ArrayType>(Type)) {
+    SmallVector<Value *> Args{
+        /*SigElementId=*/B.getInt32(SigId),
+        /*RowIndex=*/B.getInt32(Row),
+        /*ColIndex=*/B.getInt8(0),
+        /*GsVertexOrPrimIndex=*/llvm::PoisonValue::get(B.getInt32Ty())};
+    llvm::Value *Result =
+        B.CreateCall(IntrFn, Args, OB, Twine(Name).concat(Twine(Row++)));
+    assert(Row == Shape.Rows && "unexpected number of semantic rows");
+    return Result;
+  }
+
+  struct LoadItem {
+    llvm::ArrayType *Type;
+    llvm::Value *Aggregate;
+    unsigned NextIndex;
+  };
+
+  SmallVector<LoadItem> Worklist;
+  auto *RootTy = cast<llvm::ArrayType>(Type);
+  Worklist.push_back({RootTy, llvm::PoisonValue::get(RootTy), 0});
+
+  llvm::Value *Result = nullptr;
+  while (!Worklist.empty()) {
+    LoadItem &Frame = Worklist.back();
+
+    if (Frame.NextIndex == Frame.Type->getNumElements()) {
+      llvm::Value *Aggregate = Frame.Aggregate;
+      Worklist.pop_back();
+      if (Worklist.empty()) {
+        Result = Aggregate;
+        break;
+      }
+
+      LoadItem &Parent = Worklist.back();
+      Parent.Aggregate =
+          B.CreateInsertValue(Parent.Aggregate, Aggregate, Parent.NextIndex++);
+      continue;
+    }
+
+    llvm::Type *ElementTy = Frame.Type->getElementType();
+    if (auto *AT = dyn_cast<llvm::ArrayType>(ElementTy)) {
+      Worklist.push_back({AT, llvm::PoisonValue::get(AT), 0});
+      continue;
+    }
+
+    SmallVector<Value *> Args{
+        /*SigElementId=*/B.getInt32(SigId),
+        /*RowIndex=*/B.getInt32(Row),
+        /*ColIndex=*/B.getInt8(0),
+        /*GsVertexOrPrimIndex=*/llvm::PoisonValue::get(B.getInt32Ty())};
+    llvm::Value *Elt =
+        B.CreateCall(IntrFn, Args, OB, Twine(Name).concat(Twine(Row++)));
+    Frame.Aggregate =
+        B.CreateInsertValue(Frame.Aggregate, Elt, Frame.NextIndex++);
+  }
+  assert(Row == Shape.Rows && "unexpected number of semantic rows");
+  return Result;
 }
 
 void CGHLSLRuntime::emitDXILUserSemanticStore(llvm::IRBuilder<> &B,
                                               llvm::Value *Source,
+                                              const clang::DeclaratorDecl 
*Decl,
                                               HLSLAppliedSemanticAttr 
*Semantic,
                                               std::optional<unsigned> Index) {
-  // DXIL packing rules etc shall be handled here.
-  // FIXME: generate proper sigpoint, index, col, row values.
-  SmallVector<Value *> Args{B.getInt32(4),
-                            B.getInt32(0),
-                            B.getInt32(0),
-                            B.getInt8(0),
-                            llvm::PoisonValue::get(B.getInt32Ty()),
-                            Source};
+  SemanticShape Shape =
+      getSemanticShape(CGM.getContext(), getSemanticLeafType(Decl));
+  llvm::Type *RowTy = CGM.getTypes().ConvertTypeForMem(Shape.RowType);
 
-  llvm::Intrinsic::ID IntrinsicID = llvm::Intrinsic::dx_store_output;
+  llvm::Function *IntrFn = llvm::Intrinsic::getOrInsertDeclaration(
+      B.GetInsertBlock()->getModule(), llvm::Intrinsic::dx_store_output,
+      {RowTy});
 
   SmallVector<OperandBundleDef, 1> OB;
   if (auto *Token = getConvergenceToken(*B.GetInsertBlock())) {
@@ -1191,9 +1285,34 @@ void 
CGHLSLRuntime::emitDXILUserSemanticStore(llvm::IRBuilder<> &B,
     OB.emplace_back("convergencectrl", bundleArgs);
   }
 
-  llvm::Function *IntrFn = llvm::Intrinsic::getOrInsertDeclaration(
-      B.GetInsertBlock()->getModule(), IntrinsicID, {Source->getType()});
-  B.CreateCall(IntrFn, Args, OB);
+  unsigned SigId = DXILOutputSemanticIndex++;
+  unsigned Row = 0;
+
+  struct StoreItem {
+    llvm::Value *Aggregate;
+    std::optional<unsigned> Index;
+  };
+
+  SmallVector<StoreItem> Worklist{{Source, std::nullopt}};
+  while (!Worklist.empty()) {
+    StoreItem Item = Worklist.pop_back_val();
+    llvm::Value *Val = Item.Index
+                           ? B.CreateExtractValue(Item.Aggregate, *Item.Index)
+                           : Item.Aggregate;
+
+    if (auto *AT = dyn_cast<llvm::ArrayType>(Val->getType())) {
+      // Push elements in reverse so index 0 is visited first
+      for (unsigned I = AT->getNumElements(); I-- > 0;)
+        Worklist.push_back({Val, I});
+      continue;
+    }
+
+    SmallVector<Value *> Args{/*SigElementId=*/B.getInt32(SigId),
+                              /*RowIndex=*/B.getInt32(Row++),
+                              /*ColIndex=*/B.getInt8(0), /*Value=*/Val};
+    B.CreateCall(IntrFn, Args, OB);
+  }
+  assert(Row == Shape.Rows && "unexpected number of semantic rows");
 }
 
 llvm::Value *CGHLSLRuntime::emitUserSemanticLoad(
@@ -1203,7 +1322,7 @@ llvm::Value *CGHLSLRuntime::emitUserSemanticLoad(
     return emitSPIRVUserSemanticLoad(B, Type, Decl, Semantic, Index);
 
   if (CGM.getTarget().getTriple().isDXIL())
-    return emitDXILUserSemanticLoad(B, Type, Semantic, Index);
+    return emitDXILUserSemanticLoad(B, Type, Decl, Semantic, Index);
 
   llvm_unreachable("Unsupported target for user-semantic load.");
 }
@@ -1216,7 +1335,7 @@ void CGHLSLRuntime::emitUserSemanticStore(IRBuilder<> &B, 
llvm::Value *Source,
     return emitSPIRVUserSemanticStore(B, Source, Decl, Semantic, Index);
 
   if (CGM.getTarget().getTriple().isDXIL())
-    return emitDXILUserSemanticStore(B, Source, Semantic, Index);
+    return emitDXILUserSemanticStore(B, Source, Decl, Semantic, Index);
 
   llvm_unreachable("Unsupported target for user-semantic load.");
 }
@@ -1271,7 +1390,7 @@ llvm::Value *CGHLSLRuntime::emitSystemSemanticLoad(
                                       Semantic->getAttrName()->getName(),
                                       /* BuiltIn::FragCoord */ 15);
       if (CGM.getTarget().getTriple().isDXIL())
-        return emitDXILUserSemanticLoad(B, Type, Semantic, Index);
+        return emitDXILUserSemanticLoad(B, Type, Decl, Semantic, Index);
     }
 
     if (ST == Triple::EnvironmentType::Vertex) {
@@ -1286,7 +1405,7 @@ llvm::Value *CGHLSLRuntime::emitSystemSemanticLoad(
                                       Semantic->getAttrName()->getName(),
                                       /* BuiltIn::VertexIndex */ 42);
       else
-        return emitDXILUserSemanticLoad(B, Type, Semantic, Index);
+        return emitDXILUserSemanticLoad(B, Type, Decl, Semantic, Index);
     }
   }
 
@@ -1316,7 +1435,7 @@ void CGHLSLRuntime::emitSystemSemanticStore(IRBuilder<> 
&B, llvm::Value *Source,
   std::string SemanticName = Semantic->getAttrName()->getName().upper();
   if (SemanticName == "SV_POSITION") {
     if (CGM.getTarget().getTriple().isDXIL()) {
-      emitDXILUserSemanticStore(B, Source, Semantic, Index);
+      emitDXILUserSemanticStore(B, Source, Decl, Semantic, Index);
       return;
     }
 
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index cf47b1633fd3c..bbd9d59a4de4c 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -340,6 +340,7 @@ class CGHLSLRuntime {
                                          HLSLAppliedSemanticAttr *Semantic,
                                          std::optional<unsigned> Index);
   llvm::Value *emitDXILUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
+                                        const clang::DeclaratorDecl *Decl,
                                         HLSLAppliedSemanticAttr *Semantic,
                                         std::optional<unsigned> Index);
   llvm::Value *emitUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
@@ -352,6 +353,7 @@ class CGHLSLRuntime {
                                   HLSLAppliedSemanticAttr *Semantic,
                                   std::optional<unsigned> Index);
   void emitDXILUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
+                                 const clang::DeclaratorDecl *Decl,
                                  HLSLAppliedSemanticAttr *Semantic,
                                  std::optional<unsigned> Index);
   void emitUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
@@ -368,6 +370,12 @@ class CGHLSLRuntime {
   llvm::DenseMap<const clang::RecordType *, llvm::StructType *> LayoutTypes;
   unsigned SPIRVLastAssignedInputSemanticLocation = 0;
   unsigned SPIRVLastAssignedOutputSemanticLocation = 0;
+
+  // DXIL assigns each leaf semantic an index in parse order. Inputs and 
outputs
+  // are counted independently. Reset in emitEntryFunction before lowering the
+  // semantics of an entry point.
+  unsigned DXILInputSemanticIndex = 0;
+  unsigned DXILOutputSemanticIndex = 0;
 };
 
 } // namespace CodeGen
diff --git a/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl 
b/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl
index b118ee395f7de..ac695b1f7d5eb 100644
--- a/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/SV_Position.ps.hlsl
@@ -9,9 +9,9 @@ float4 main(float4 p : SV_Position) : A {
   // CHECK-SPIRV: %[[#R:]] = call spir_func <4 x float> @_Z4mainDv4_f(<4 x 
float> %[[#P]])
   // CHECK-SPIRV:            store <4 x float> %[[#R]], ptr addrspace(8) @A0, 
align 4
 
-  // CHECK-DXIL: %SV_Position0 = call <4 x float> 
@llvm.dx.load.input.v4f32(i32 4, i32 0, i32 0, i8 0, i32 poison)
+  // CHECK-DXIL: %SV_Position0 = call <4 x float> 
@llvm.dx.load.input.v4f32(i32 0, i32 0, i8 0, i32 poison)
   // CHECK-DXIL:    %[[#TMP:]] = call <4 x float> @_Z4mainDv4_f(<4 x float> 
%SV_Position0)
-  // CHECK-DXIL:                 call void @llvm.dx.store.output.v4f32(i32 4, 
i32 0, i32 0, i8 0, i32 poison, <4 x float> %[[#TMP]])
+  // CHECK-DXIL:                 call void @llvm.dx.store.output.v4f32(i32 0, 
i32 0, i8 0, <4 x float> %[[#TMP]])
   return p;
 }
 
diff --git a/clang/test/CodeGenHLSL/semantics/SV_Position.vs.hlsl 
b/clang/test/CodeGenHLSL/semantics/SV_Position.vs.hlsl
index caab744c1fa98..350b5e3612e32 100644
--- a/clang/test/CodeGenHLSL/semantics/SV_Position.vs.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/SV_Position.vs.hlsl
@@ -10,9 +10,9 @@ float4 main(float4 p : SV_Position) : SV_Position {
   // CHECK-SPIRV: %[[#R:]] = call spir_func <4 x float> @_Z4mainDv4_f(<4 x 
float> %[[#P]])
   // CHECK-SPIRV:            store <4 x float> %[[#R]], ptr addrspace(8) 
@SV_Position, align 4
 
-  // CHECK-DXIL: %SV_Position0 = call <4 x float> 
@llvm.dx.load.input.v4f32(i32 4, i32 0, i32 0, i8 0, i32 poison)
+  // CHECK-DXIL: %SV_Position0 = call <4 x float> 
@llvm.dx.load.input.v4f32(i32 0, i32 0, i8 0, i32 poison)
   // CHECK-DXIL:    %[[#TMP:]] = call <4 x float> @_Z4mainDv4_f(<4 x float> 
%SV_Position0)
-  // CHECK-DXIL:                 call void @llvm.dx.store.output.v4f32(i32 4, 
i32 0, i32 0, i8 0, i32 poison, <4 x float> %[[#TMP]])
+  // CHECK-DXIL:                 call void @llvm.dx.store.output.v4f32(i32 0, 
i32 0, i8 0, <4 x float> %[[#TMP]])
   return p;
 }
 
diff --git a/clang/test/CodeGenHLSL/semantics/SV_Target.ps.hlsl 
b/clang/test/CodeGenHLSL/semantics/SV_Target.ps.hlsl
index 1ab4df4f61bd7..73255e3a9b939 100644
--- a/clang/test/CodeGenHLSL/semantics/SV_Target.ps.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/SV_Target.ps.hlsl
@@ -9,7 +9,7 @@ float4 main(float4 p : SV_Position) : SV_Target {
   // CHECK-SPIRV:            store <4 x float> %[[#R]], ptr addrspace(8) 
@SV_Target0, align 4
 
   // CHECK-DXIL:    %[[#TMP:]] = call <4 x float> @_Z4mainDv4_f(<4 x float> 
%SV_Position0)
-  // CHECK-DXIL:                 call void @llvm.dx.store.output.v4f32(i32 4, 
i32 0, i32 0, i8 0, i32 poison, <4 x float> %[[#TMP]])
+  // CHECK-DXIL:                 call void @llvm.dx.store.output.v4f32(i32 0, 
i32 0, i8 0, <4 x float> %[[#TMP]])
   return p;
 }
 
diff --git a/clang/test/CodeGenHLSL/semantics/SV_VertexID.vs.hlsl 
b/clang/test/CodeGenHLSL/semantics/SV_VertexID.vs.hlsl
index e2c184ac7948c..491f10b530c38 100644
--- a/clang/test/CodeGenHLSL/semantics/SV_VertexID.vs.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/SV_VertexID.vs.hlsl
@@ -8,7 +8,7 @@ uint main(uint id : SV_VertexID) : A {
   // CHECK-SPIRV: %[[#P:]] = load i32, ptr addrspace(7) @SV_VertexID, align 4
   // CHECK-SPIRV:   %[[#]] = call spir_func i32 @_Z4mainj(i32 %[[#P]])
 
-  // CHECK-DXIL: %SV_VertexID0 = call i32 @llvm.dx.load.input.i32(i32 4, i32 
0, i32 0, i8 0, i32 poison)
+  // CHECK-DXIL: %SV_VertexID0 = call i32 @llvm.dx.load.input.i32(i32 0, i32 
0, i8 0, i32 poison)
   // CHECK-DXIL:        %[[#]] = call i32 @_Z4mainj(i32 %SV_VertexID0)
   return id;
 }
diff --git a/clang/test/CodeGenHLSL/semantics/semantic.arbitrary.hlsl 
b/clang/test/CodeGenHLSL/semantics/semantic.arbitrary.hlsl
index 1ea2827660307..720dafcd4f1b6 100644
--- a/clang/test/CodeGenHLSL/semantics/semantic.arbitrary.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/semantic.arbitrary.hlsl
@@ -14,9 +14,9 @@ void main(float a : AAA, int b : B, float2 c : CC) {
 
 // CHECK: define void @main()
 
-// CHECK-DXIL: %AAA0 = call float @llvm.dx.load.input.f32(i32 4, i32 0, i32 0, 
i8 0, i32 poison)
-// CHECK-DXIL:   %B0 = call i32 @llvm.dx.load.input.i32(i32 4, i32 0, i32 0, 
i8 0, i32 poison)
-// CHECK-DXIL   %CC0 = call <2 x float> @llvm.dx.load.input.v2f32(i32 4, i32 
0, i32 0, i8 0, i32 poison)
+// CHECK-DXIL: %AAA0 = call float @llvm.dx.load.input.f32(i32 0, i32 0, i8 0, 
i32 poison)
+// CHECK-DXIL:   %B0 = call i32 @llvm.dx.load.input.i32(i32 1, i32 0, i8 0, 
i32 poison)
+// CHECK-DXIL   %CC0 = call <2 x float> @llvm.dx.load.input.v2f32(i32 2, i32 
0, i8 0, i32 poison)
 // CHECK-DXIL:         call void @_Z4mainfiDv2_f(float %AAA0, i32 %B0, <2 x 
float> %CC0)
 
 // CHECK-SPIRV: %[[#AAA0:]] = load float, ptr addrspace(7) @AAA0, align 4
diff --git a/clang/test/CodeGenHLSL/semantics/semantic.array.hlsl 
b/clang/test/CodeGenHLSL/semantics/semantic.array.hlsl
index c62c4d4a517f2..5466948bd32bc 100644
--- a/clang/test/CodeGenHLSL/semantics/semantic.array.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/semantic.array.hlsl
@@ -12,10 +12,13 @@ struct S0 {
 // CHECK-SPIRV: @A2 = external hidden thread_local addrspace(7) 
externally_initialized constant <4 x float>, !spirv.Decorations ![[#MD_2:]]
 
 // CHECK:       define void @main0()
-// CHECK-DXIL:          %A0 = call [2 x <4 x float>] 
@llvm.dx.load.input.a2v4f32(i32 4, i32 0, i32 0, i8 0, i32 poison)
-// CHECK-DXIL:  %[[#TMP0:]] = insertvalue %struct.S0 poison, [2 x <4 x float>] 
%A0, 0
-// CHECK-DXIL:          %A2 = call <4 x float> @llvm.dx.load.input.v4f32(i32 
4, i32 0, i32 0, i8 0, i32 poison)
-// CHECK-DXIL:  %[[#TMP1:]] = insertvalue %struct.S0 %[[#TMP0]], <4 x float> 
%A2, 1
+// CHECK-DXIL:          %A0 = call <4 x float> @llvm.dx.load.input.v4f32(i32 
0, i32 0, i8 0, i32 poison)
+// CHECK-DXIL: %[[#POS0:]] = insertvalue [2 x <4 x float>] poison, <4 x float> 
%A0, 0
+// CHECK-DXIL:          %A1 = call <4 x float> @llvm.dx.load.input.v4f32(i32 
0, i32 1, i8 0, i32 poison)
+// CHECK-DXIL: %[[#POS1:]] = insertvalue [2 x <4 x float>] %[[#POS0]], <4 x 
float> %A1, 1
+// CHECK-DXIL: %[[#TMP0:]] = insertvalue %struct.S0 poison, [2 x <4 x float>] 
%[[#POS1]], 0
+// CHECK-DXIL:        %A01 = call <4 x float> @llvm.dx.load.input.v4f32(i32 1, 
i32 0, i8 0, i32 poison)
+// CHECK-DXIL: %[[#TMP1:]] = insertvalue %struct.S0 %[[#TMP0]], <4 x float> 
%A01, 1
 
 // CHECK-SPIRV:   %[[#A0:]] = load [2 x <4 x float>], ptr addrspace(7) @A0, 
align 4
 // CHECK-SPIRV: %[[#TMP0:]] = insertvalue %struct.S0 poison, [2 x <4 x float>] 
%[[#A0]], 0
diff --git a/clang/test/CodeGenHLSL/semantics/semantic.array.output.hlsl 
b/clang/test/CodeGenHLSL/semantics/semantic.array.output.hlsl
index 18942699aaa2c..9d3afc5e8fba6 100644
--- a/clang/test/CodeGenHLSL/semantics/semantic.array.output.hlsl
+++ b/clang/test/CodeGenHLSL/semantics/semantic.array.output.hlsl
@@ -12,17 +12,20 @@ struct S0 {
 S0 main1(float4 input : A) : B {
 // CHECK:         %[[#ARG:]] = alloca %struct.S0
 // CHECK-SPIRV: %[[#INPUT:]] = load <4 x float>, ptr addrspace(7) @A0, align 4
-// CHECK-DXIL:           %A0 = call <4 x float> @llvm.dx.load.input.v4f32(i32 
4, i32 0, i32 0, i8 0, i32 poison)
+// CHECK-DXIL:           %A0 = call <4 x float> @llvm.dx.load.input.v4f32(i32 
0, i32 0, i8 0, i32 poison)
 // CHECK-DXIL:                 call void @{{.*}}main1{{.*}}(ptr %[[#ARG]], <4 
x float> %A0)
 // CHECK-SPIRV:                call spir_func void @{{.*}}main1{{.*}}(ptr 
%[[#ARG]], <4 x float> %[[#INPUT]])
 
   // CHECK:        %[[#ST:]] = load %struct.S0, ptr %[[#ARG]]
   // CHECK:       %[[#TMP:]] = extractvalue %struct.S0 %[[#ST]], 0
   // CHECK-SPIRV:              store [2 x <4 x float>] %[[#TMP]], ptr 
addrspace(8) @B0, align 4
-  // CHECK-DXIL:               call void @llvm.dx.store.output.a2v4f32(i32 4, 
i32 0, i32 0, i8 0, i32 poison, [2 x <4 x float>] %[[#TMP]])
+  // CHECK-DXIL:  %[[#POS0:]] = extractvalue [2 x <4 x float>] %[[#TMP]], 0
+  // CHECK-DXIL:               call void @llvm.dx.store.output.v4f32(i32 0, 
i32 0, i8 0, <4 x float> ...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/212656
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to