[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
Tue Feb 24 10:48:57 PST 2026
================
@@ -2450,6 +2450,20 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
llvm::Value *Init = llvm::Constant::getNullValue(EltTy);
V = Builder.CreateInsertElement(V, Init, Idx, "vecinit");
}
+
+ // Matrix initializer lists are in row-major order but the memory layout for
+ // codegen is determined by the -fmatrix-memory-layout flag (default:
+ // column-major). When the memory layout is column-major, we need to shuffle
+ // the elements from row-major to column-major order.
+ if (const auto *MT = E->getType()->getAs<ConstantMatrixType>()) {
+ if (CGF.getLangOpts().getDefaultMatrixMemoryLayout() !=
+ LangOptions::MatrixMemoryLayout::MatrixRowMajor) {
----------------
Icohedron wrote:
Since there are only two options, it doesn't really make a difference and I don't have a strong preference.
So I can make the change.
https://github.com/llvm/llvm-project/pull/182904
More information about the cfe-commits
mailing list