[clang] [lldb] [llvm] [OpenCL][Clang] Add support for cooperative matrix extension (PR #221328)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 17 21:25:12 PDT 2026


================
@@ -15693,6 +15877,17 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   if (getLangOpts().OpenCL) {
     QualType LHSTy = LHSExpr->getType();
     QualType RHSTy = RHSExpr->getType();
+    // Cooperative matrix support
+    if (LHSTy->isCooperativeMatrixType() && RHSTy->isCooperativeMatrixType()) {
+      // Check matrix types for assignment.
+      if (BO_Assign == Opc) {
+        if (CheckCoopMatrixTypes(LHSTy, LHSExpr->getBeginLoc(), RHSTy,
+                                 RHSExpr->getBeginLoc()))
+          return ExprError();
+      } else
+        return CreateCoopMatBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
+    } else if (LHSTy->isCooperativeMatrixType() && RHSTy->isScalarType())
+      return CreateCoopMatScalarOp(OpLoc, Opc, LHSExpr, RHSExpr);
----------------
asudarsa-qti wrote:

Good catch. I have tried to fix this by interchanging the arguments to CreateCoopMatScalarOp if LHS is scalar.
Fixed in e1f7a4c795d5d2e0f2c84d70eab83102e0d7ca2a

Thanks

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


More information about the cfe-commits mailing list