[clang] [HLSL] Preserve matrix layout as AST storage metadata (PR #225519)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 23 19:53:14 PDT 2026
================
@@ -2259,9 +2256,8 @@ Value *ScalarExprEmitter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
Value *Idx;
unsigned NumCols = MatrixTy->getNumColumns();
unsigned NumRows = MatrixTy->getNumRows();
- bool IsMatrixRowMajor =
- isMatrixRowMajor(CGF.getLangOpts(), E->getBase()->getType());
- Idx = MB.CreateIndex(RowIdx, ColumnIdx, NumRows, NumCols, IsMatrixRowMajor);
+ Idx = MB.CreateIndex(RowIdx, ColumnIdx, NumRows, NumCols,
+ /*IsRowMajor=*/false);
----------------
farzonl wrote:
Its a good question and the reason why this test is failing right now https://github.com/llvm/llvm-project/blob/fbf3c11ccd65fee37c80c9c00c0c4ab638388fe0/clang/test/CodeGen/matrix-type-indexing.c#L18-L30
I introduced this row major\column major toggling behavior to c\c++. Before I did that `MB.CreateIndex` default behavior was column major. I think it might be easer for c\c++ to do what we are now doing for HLSL and just updat the tests to show that matrix indexing will be stable across row\column major but row major will account for that with transpose operations.
So TLDR yes it was intentional, i'm fixing an issue I created in c\c++ myself.
https://github.com/llvm/llvm-project/pull/225519
More information about the cfe-commits
mailing list