[clang] [Headers][X86] VectorExprEvaluator::VisitCallExpr - allow SSE/AVX2/AVX512 pack intrinsics to be used in constexpr (PR #156003)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 24 00:40:39 PDT 2025
================
@@ -11575,6 +11575,46 @@ static bool handleVectorElementCast(EvalInfo &Info, const FPOptions FPO,
return false;
}
+static bool evalPackBuiltin(const CallExpr *E, EvalInfo &Info, APValue &Result,
+ llvm::function_ref<APInt(const APSInt &)> PackFn) {
+ APValue LHS, RHS;
+ if (!EvaluateAsRValue(Info, E->getArg(0), LHS) ||
+ !EvaluateAsRValue(Info, E->getArg(1), RHS))
+ return false;
+
+ unsigned LHSVecLen = LHS.getVectorLength();
+ unsigned RHSVecLen = RHS.getVectorLength();
+
+ assert(LHSVecLen != 0 && LHSVecLen == RHSVecLen &&
+ "pack builtin LHSVecLen must equal to RHSVecLen");
+
+ const VectorType *VT0 = E->getArg(0)->getType()->castAs<VectorType>();
+ const unsigned SrcBits = Info.Ctx.getIntWidth(VT0->getElementType());
+
+ const VectorType *DstVT = E->getType()->castAs<VectorType>();
+ QualType DstElemTy = DstVT->getElementType();
+ const bool DstIsUnsigned = DstElemTy->isUnsignedIntegerType();
+
+ const unsigned srcPerLane = 128 / SrcBits;
----------------
RKSimon wrote:
(style) Capitalize first letter of variables: SrcPerLane, Lanes, Lane, I etc.
https://github.com/llvm/llvm-project/pull/156003
More information about the cfe-commits
mailing list