[PATCH] math: Order signed zeros in fmin and fmax.

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Dec 22 14:53:24 GMT 2025



On 21/12/25 01:31, James Y Knight wrote:
> On Sat, Dec 20, 2025 at 12:53 PM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>> Does this work on all targets that have hardware fmin/fmax?
> 
> I believe the patch results in the desired behavior on all targets,
> even though it modifies only the i386, i686, x86_64, and the generic C
> implementation.

As a side note, I don't think there is much gain is having the i386 version.
If you a felling adventurous, maybe you can send a patch to just remove the
i386 variants and making the i686 the default one.

> 
> The additional targets in glibc which don't use the generic C
> implementation are:
> - riscv
> - loongarch (via setting USE_F{MIN,MAX}{,F}_BUILTIN)
> - aarch64 (via setting USE_F{MIN,MAX}{,F}_BUILTIN)
> 
> On these architectures, the operation is already implemented by a
> single hardware instruction with the desired behavior; no changes are
> required.
> 
>> There are at least
>> 3 different variations of fmin/fmax in the IEEE standard, so I'm wondering whether
>> they do agree on how to handle signed zeroes... If it works on all modern targets,
>> that's great, but that's not clear from your description because ISAs typically
>> follow IEEE specs.
> 
> Yes, the other variations of floating-point min/max are fminimum,
> fminimum_mag, fminimum_num, fminimum_mag_num (and their corresponding
> maximums). Those functions are required to order signed zeros by the C
> standard, unlike fmin/fmax where it is only recommended.
> 
> James



More information about the Libc-alpha mailing list