[clang] [Headers][X86] Allow AVX512 masked arithmetic intrinsics to be used in constexpr (PR #162816)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 15 10:56:10 PDT 2025
================
@@ -11705,6 +11705,23 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
return Success(APValue(ResultElements.data(), SourceLen), E);
};
+ auto EvalSelectScalar = [&](unsigned Len) -> std::optional<APValue> {
+ APSInt Mask;
+ APValue AVal, WVal;
+ if (!EvaluateInteger(E->getArg(0), Mask, Info) ||
+ !EvaluateAsRValue(Info, E->getArg(1), AVal) ||
+ !EvaluateAsRValue(Info, E->getArg(2), WVal))
+ return std::nullopt;
+
+ const bool TakeA0 = (Mask.getZExtValue() & 1u) != 0;
+ SmallVector<APValue, 4> Res;
+ Res.reserve(Len);
+ Res.push_back(TakeA0 ? AVal.getVectorElt(0) : WVal.getVectorElt(0));
+ for (unsigned i = 1; i < Len; ++i)
+ Res.push_back(WVal.getVectorElt(i));
+ return APValue(Res.data(), Res.size());
----------------
RKSimon wrote:
why not just return Success / false?
https://github.com/llvm/llvm-project/pull/162816
More information about the cfe-commits
mailing list