[clang] [llvm] APFloat: Fix maxnum and minnum with sNaN (PR #112854)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 21 10:33:13 PDT 2024


================
@@ -15338,16 +15338,11 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_fmaxl:
   case Builtin::BI__builtin_fmaxf16:
   case Builtin::BI__builtin_fmaxf128: {
-    // TODO: Handle sNaN.
     APFloat RHS(0.);
     if (!EvaluateFloat(E->getArg(0), Result, Info) ||
         !EvaluateFloat(E->getArg(1), RHS, Info))
       return false;
-    // When comparing zeroes, return +0.0 if one of the zeroes is positive.
-    if (Result.isZero() && RHS.isZero() && Result.isNegative())
-      Result = RHS;
-    else if (Result.isNaN() || RHS > Result)
-      Result = RHS;
+    Result = maxnum(Result, RHS);
----------------
arsenm wrote:

This is a separate change to fix reimplementing it in clang

https://github.com/llvm/llvm-project/pull/112854


More information about the cfe-commits mailing list