================
@@ -12280,6 +12280,42 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr
*E) {
return Success(APValue(ResultElements.data(), SourceLen), E);
};
+ auto EvaluateFpBinOpExpr =
+ [&](llvm::function_ref<APFloat(const APFloat &, const APFloat &,
+ std::optional<APSInt>)>
+ Fn) {
+ assert(E->getNumArgs() == 2 || E->getNumArgs() == 3);
+ APValue A, B;
+ if (!EvaluateAsRValue(Info, E->getArg(0), A) ||
+ !EvaluateAsRValue(Info, E->getArg(1), B))
+ return false;
+
+ assert(A.isVector() && B.isVector());
+ assert(A.getVectorLength() == B.getVectorLength());
+
+ std::optional<APSInt> RoundingMode;
+ if (E->getNumArgs() == 3) {
+ APSInt Imm;
+ if (!EvaluateInteger(E->getArg(2), Imm, Info))
+ return false;
+ RoundingMode = Imm;
+ }
+
+ unsigned NumElems = A.getVectorLength();
+ SmallVector<APValue, 4> ResultElements;
+ ResultElements.reserve(NumElems);
+
+ for (unsigned EltNum = 0; EltNum < NumElems; ++EltNum) {
+ const APFloat &EltA = A.getVectorElt(EltNum).getFloat();
+ const APFloat &EltB = B.getVectorElt(EltNum).getFloat();
+ if (EltA.isNaN() || EltA.isInfinity() || EltA.isDenormal() ||
----------------
shafik wrote:
Are any of these cases covered in the tests? I don't see it either by eye or by
searching but maybe I am missing it.
https://github.com/llvm/llvm-project/pull/171966
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits