================
@@ -7806,6 +7806,39 @@ ExprResult Sema::prepareVectorSplat(QualType VectorTy,
Expr *SplattedExpr) {
return ImpCastExprToType(SplattedExpr, DestElemTy, CK);
}
+ExprResult Sema::prepareMatrixSplat(QualType MatrixTy, Expr *SplattedExpr) {
+ QualType DestElemTy = MatrixTy->castAs<MatrixType>()->getElementType();
+
+ if (DestElemTy == SplattedExpr->getType())
+ return SplattedExpr;
+
+ assert(DestElemTy->isFloatingType() ||
+ DestElemTy->isIntegralOrEnumerationType());
+
+ 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.
----------------
tex3d wrote:
Do we have testing for this path?
HLSL doesn't define the result of a cast of a true `bool` to `int` to be `-1`,
regardless of whether it's scalar, vector, or matrix.
Is this an OpenCL-specific detail? In `CheckVectorCast` it says:
>// OpenCL requires that we convert `true` boolean expressions to -1, but
>// only when splatting vectors.
Though this isn't the code which defines the behavior of the cast itself, so
those details in this comment do seem misplaced.
https://github.com/llvm/llvm-project/pull/170885
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits