[clang] [llvm] [HLSL][Matrix] Make Matrix InitListExprs and AST row-major order, and respect /Zpr and /Zpc in codegen (PR #182904)

Deric C. via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 23 12:07:15 PST 2026


================
@@ -1915,10 +1915,11 @@ void InitListChecker::CheckMatrixType(const InitializedEntity &Entity,
 
   while (Index < IList->getNumInits()) {
     // Not a sublist: just consume directly.
-    unsigned ColMajorIndex = (Index % MT->getNumRows()) * MT->getNumColumns() +
-                             (Index / MT->getNumRows());
-    ElemEnt.setElementIndex(ColMajorIndex);
-    CheckSubElementType(ElemEnt, IList, ElemTy, ColMajorIndex, StructuredList,
+    // Note: In HLSL, elements of the InitListExpr are in row-major order, so no
+    // change is needed to the Index.
+    unsigned RowMajorIdx = Index;
+    ElemEnt.setElementIndex(RowMajorIdx);
+    CheckSubElementType(ElemEnt, IList, ElemTy, RowMajorIdx, StructuredList,
----------------
Icohedron wrote:

The intermediate `RowMajorIdx` variable is actually necessary. Removing it and using `Index` directly caused test failures because the `CheckSubElementType` function modifies it.

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


More information about the cfe-commits mailing list