[clang] [Matrix] For MatrixRow with constant index use Indices.size() instead of getNumColumns() (PR #185530)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 20 22:46:32 PDT 2026
================
@@ -5415,26 +5415,30 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
return LValue::MakeExtVectorElt(Base.getAddress(), CV, type,
Base.getBaseInfo(), TBAAAccessInfo());
}
+
if (Base.isMatrixRow()) {
if (auto *RowIdx =
llvm::dyn_cast<llvm::ConstantInt>(Base.getMatrixRowIdx())) {
llvm::SmallVector<llvm::Constant *> MatIndices;
QualType MatTy = Base.getType();
const ConstantMatrixType *MT = MatTy->castAs<ConstantMatrixType>();
- unsigned NumCols = MT->getNumColumns();
+ unsigned NumCols = Indices.size();
unsigned NumRows = MT->getNumRows();
- MatIndices.reserve(NumCols);
-
unsigned Row = RowIdx->getZExtValue();
+ QualType VecQT = E->getBase()->getType();
+ if (NumCols != MT->getNumColumns()) {
+ const auto *EVT = VecQT->getAs<ExtVectorType>();
----------------
shafik wrote:
We have three branches above two of those do an assert Base is a VectorType but the third does not. So this looks like an unsafe assumption that `getAs<ExtVectorType>()` will give us a non-nullptr.
https://github.com/llvm/llvm-project/pull/185530
More information about the cfe-commits
mailing list