[llvm-branch-commits] [clang] [HLSL][Matrix] Add Matrix splat support for booleans (PR #175809)

Farzon Lotfi via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 13 11:00:43 PST 2026


================
@@ -7899,14 +7899,26 @@ ExprResult Sema::prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr) {
   assert(DestElemTy->isFloatingType() ||
          DestElemTy->isIntegralOrEnumerationType());
 
-  // TODO: Add support for boolean matrix once exposed
-  // https://github.com/llvm/llvm-project/issues/170920
-  ExprResult CastExprRes = SplattedExpr;
-  CastKind CK = PrepareScalarCast(CastExprRes, DestElemTy);
-  if (CastExprRes.isInvalid())
-    return ExprError();
-  SplattedExpr = CastExprRes.get();
-
+  CastKind CK;
+  if (SplattedExpr->getType()->isBooleanType()) {
+    // As with vectors, we want `true` to become -1 when splatting, and we
+    // need a two-step cast if the destination element type is floating.
+    if (DestElemTy->isFloatingType()) {
+      // Cast boolean to signed integral, then to floating.
+      ExprResult CastExprRes = ImpCastExprToType(SplattedExpr, Context.IntTy,
+                                                 CK_BooleanToSignedIntegral);
+      SplattedExpr = CastExprRes.get();
+      CK = CK_IntegralToFloating;
+    } else {
+      CK = CK_BooleanToSignedIntegral;
+    }
----------------
farzonl wrote:

The issue was more a theory for why boolean splats were not working not perscriptive. the boolean prs and splat prs were going on simultaneously.  If this code isn't needed you don't need to put it in this pr.

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


More information about the llvm-branch-commits mailing list