================
@@ -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::MatrixColMajor) {
----------------
Icohedron wrote:

It would have to look like
```c++
  if (const auto *MT = E->getType()->getAs<ConstantMatrixType>();
      MT && CGF.getLangOpts().getDefaultMatrixMemoryLayout() ==
                LangOptions::MatrixMemoryLayout::MatrixColMajor) {
```
because of the variable declaration within the condition, but yes I can make 
this change.

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

Reply via email to