[clang] [CIR] Implement support for MatrixSingleSubstract expr (PR #232079)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 14 13:46:17 PDT 2026


================
@@ -322,13 +322,19 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
     mlir::Location loc = cgf.getLoc(e->getSourceRange());
     if (cgf.cgm.getCodeGenOpts().OptimizationLevel > 0)
       assert(!cir::MissingFeatures::emitMatrixIndexAssumption());
-    return builder.createMatrixExtract(loc, matrix, rowIdx, columnIdx);
+    mlir::Type resultTy = convertType(e->getType());
+    return builder.createMatrixExtract(loc, resultTy, matrix, rowIdx,
+                                       columnIdx);
   }
 
   mlir::Value VisitMatrixSingleSubscriptExpr(MatrixSingleSubscriptExpr *e) {
-    cgf.cgm.errorNYI(e->getSourceRange(),
-                     "ScalarExprEmitter: matrix singel subscript");
-    return {};
+    mlir::Value rowIdx = cgf.emitScalarExpr(e->getRowIdx());
+    if (cgf.cgm.getCodeGenOpts().OptimizationLevel > 0)
+      assert(!cir::MissingFeatures::emitMatrixIndexAssumption());
----------------
erichkeane wrote:

This wont work in non-asserts build, as the 'if' will 'eat' the matrix definition next, since the assert wont exist.I see the above 324 screwed this up as well!

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


More information about the cfe-commits mailing list