[clang] [HLSL][Matrix] Allow flattening matrix types in FlattenAccessAndTypeLValue (PR #177708)

Deric C. via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 23 18:35:30 PST 2026


================
@@ -7192,6 +7190,25 @@ void CodeGenFunction::FlattenAccessAndTypeLValue(
                                   Base.getBaseInfo(), TBAAAccessInfo());
         AccessList.emplace_back(LV);
       }
+    } else if (const auto *MT = dyn_cast<ConstantMatrixType>(T)) {
+      // Matrices are represented as flat arrays in memory, but has a vector
+      // value type. So we use ConvertMatrixAddress to convert the address from
+      // array to vector, and extract elements similar to the vector case above.
+      // The order in which we iterate over the elements is sequentially in
+      // memory; whether the matrix is in row- or column-major order does not
+      // matter.
----------------
Icohedron wrote:

Actually yes, I think you are correct. This is a Clang issue and the library shader example for DXC is incorrect.

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


More information about the cfe-commits mailing list