[clang] [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - Allow SSE/AVX FP MAX/MIN intrinsics to be used in constexpr (PR #171966)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 12 01:50:57 PST 2025
================
@@ -2433,6 +2433,46 @@ static bool interp__builtin_elementwise_int_unaryop(
return true;
}
+static bool interp__builtin_elementwise_fp_binop(
+ InterpState &S, CodePtr OpPC, const CallExpr *Call,
+ llvm::function_ref<APFloat(const APFloat &, const APFloat &,
+ std::optional<APSInt> RoundingMode)>
+ Fn) {
+ assert((Call->getNumArgs() == 2) || (Call->getNumArgs() == 3));
+ const auto *VT = Call->getArg(0)->getType()->castAs<VectorType>();
+ assert(VT->getElementType()->isFloatingType());
+ unsigned NumElems = VT->getNumElements();
+
+ // Vector case.
+ assert(Call->getArg(0)->getType()->isVectorType() &&
+ Call->getArg(1)->getType()->isVectorType());
+ assert(VT->getElementType() ==
+ Call->getArg(1)->getType()->castAs<VectorType>()->getElementType());
+ assert(VT->getNumElements() ==
+ Call->getArg(1)->getType()->castAs<VectorType>()->getNumElements());
+
+ std::optional<APSInt> RoundingMode = std::nullopt;
+ if (Call->getNumArgs() == 3) {
+ RoundingMode = popToAPSInt(S, Call->getArg(2));
+ }
----------------
tbaederr wrote:
```suggestion
if (Call->getNumArgs() == 3)
RoundingMode = popToAPSInt(S, Call->getArg(2));
```
https://github.com/llvm/llvm-project/pull/171966
More information about the cfe-commits
mailing list