On x86_64, it allows the fast path (normal/subnormal inputs) to use maxsd.
With gcc-15 targetting x86_64 for fmax:
* master:
ucomisd xmm0, xmm1
jnb .L1
ucomisd xmm1, xmm0
ja .L13
[...]
.L13:
movapd xmm0, xmm1
.L1:
ret
* patch;
ucomisd xmm0, xmm1
jp .L2
maxsd xmm0, xmm1
ret
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
#if M_USE_BUILTIN (FMAX)
return M_SUF (__builtin_fmax) (x, y);
#else
- if (isgreaterequal (x, y))
- return x;
- else if (isless (x, y))
- return y;
+ if (__glibc_likely (!isunordered (x, y)))
+ return x > y ? x : y;
else if (issignaling (x) || issignaling (y))
return x + y;
else
#if M_USE_BUILTIN (FMIN)
return M_SUF (__builtin_fmin) (x, y);
#else
- if (islessequal (x, y))
- return x;
- else if (isgreater (x, y))
- return y;
+ if (__glibc_likely (!isunordered (x, y)))
+ return x > y ? y : x;
else if (issignaling (x) || issignaling (y))
return x + y;
else