[llvm] [clang] [clang-tools-extra] [HLSL] Vector standard conversions (PR #71098)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 5 14:20:54 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");
+ }
----------------
rjmccall wrote:
Okay, *please* tell me this is wrong. The result of truncating `<A,B,C,D>` to a 3-vector is `<A,A,A>`? I'm not misunderstanding something fundamental about `shufflevector` here, right?
https://github.com/llvm/llvm-project/pull/71098
More information about the cfe-commits
mailing list