================ @@ -2692,14 +2692,19 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { return CGF.CGM.createOpenCLIntToSamplerConversion(E, CGF); case CK_HLSLVectorTruncation: { - assert(DestTy->isVectorType() && "Expected dest type to be vector type"); + assert((DestTy->isVectorType() || DestTy->isBuiltinType()) && + "Destination type must be a vector or builtin type."); Value *Vec = Visit(const_cast<Expr *>(E)); - SmallVector<int, 16> Mask; - unsigned NumElts = DestTy->castAs<VectorType>()->getNumElements(); - for (unsigned I = 0; I != NumElts; ++I) - Mask.push_back(I); + if (auto *VecTy = DestTy->getAs<VectorType>()) { + SmallVector<int, 16> Mask; ---------------- bogner wrote:
It was already here, but while I see it: better to use `SmallVector<int>` and let it pick the size here https://github.com/llvm/llvm-project/pull/104844 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits