[clang] [HLSL] add support for HLSLAggregateSplatCast and HLSLElementwiseCast to constant expression evaluator (PR #164700)

Sarah Spall via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 31 08:51:46 PDT 2025


================
@@ -10851,6 +11194,68 @@ bool RecordExprEvaluator::VisitCastExpr(const CastExpr *E) {
     Result = *Value;
     return true;
   }
+  case CK_HLSLAggregateSplatCast: {
+    APValue Val;
+    const Expr *SE = E->getSubExpr();
+
+    if (!Evaluate(Val, Info, SE))
+      return Error(E);
+
+    unsigned NEls = elementwiseSize(Info, E->getType());
+    // flatten the source
+    SmallVector<APValue, 1> SrcEls;
+    SmallVector<QualType, 1> SrcTypes;
+    if (!flattenAPValue(Info.Ctx, Val, SE->getType(), SrcEls, SrcTypes, NEls))
+      return Error(E);
+
+    // check there is only one and splat it
+    assert(SrcEls.size() == 1);
+    SmallVector<APValue> SplatEls(NEls, SrcEls[0]);
+    SmallVector<QualType> SplatType(NEls, SrcTypes[0]);
+
+    APValue Tmp;
+    handleDefaultInitValue(E->getType(), Tmp);
----------------
spall wrote:

No this code should have been removed. It was for debugging reasons.

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


More information about the cfe-commits mailing list