[PATCH 07/12] math: Order signed zeros in f{max,min}mag{f,l,f128}

Wilco Dijkstra Wilco.Dijkstra@arm.com
Wed Jan 21 13:04:35 GMT 2026


Hi Adhemerval,

@@ -28,7 +28,7 @@ M_DECL_FUNC (__fmaxmag) (FLOAT x, FLOAT y)
   else if (isless (ax, ay))
     return y;
   else if (ax == ay)
-    return x > y ? x : y;
+    return signbit (x) ? y : x;
   else if (issignaling (x) || issignaling (y))
     return x + y;
   else

So for these I would use similar optimization as fmin/fmax to reduce branches
and allow targets to use conditional select/move (but use isless/isgreater):

   if (__glibc_likely (!isunordered (x, y)))
    {
      if (__glibc_unlikely (x == y))
	return signbit (x) ? y : x;
      return isgreater (x, y) ? x : y;
    }

Cheers,
Wilco


More information about the Libc-alpha mailing list