[clang] [HLSL] Vector standard conversions (PR #71098)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 10:46:59 PST 2024


================
@@ -2466,6 +2504,15 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
   case CK_IntToOCLSampler:
     return CGF.CGM.createOpenCLIntToSamplerConversion(E, CGF);
 
+  case CK_HLSLVectorTruncation: {
+    assert(DestTy->isVectorType() && "Expected dest type to be vector type");
+    Value *Vec = Visit(const_cast<Expr *>(E));
+    SmallVector<int, 16> Mask;
+    Mask.insert(Mask.begin(), DestTy->castAs<VectorType>()->getNumElements(),
+                0);
+    return Builder.CreateShuffleVector(Vec, Mask, "trunc");
+  }
----------------
llvm-beanz wrote:

Doh!

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


More information about the cfe-commits mailing list