[libc-commits] [libc] [libc] Work around incorrect fmin/fmax results for +/-x (PR #83158)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue Feb 27 09:57:12 PST 2024
jhuber6 wrote:
@arsenm I'm guessing this is a change we'll need to put in the backend at some point? The C/C++ standard seems lax on this point, but it's explicitly stated in IEEE754 2019 to have these semantics. The implementation of `fmin` in the ISA is listed as the following, which seems to provide these semantics, but looking at https://godbolt.org/z/oP8zrYh6T.
```c
// V_MIN_F64 Compute the minimum of two double-precision floats.
if (IEEE_MODE && S0.d == sNaN)
D.d = Quiet(S0.d);
else if (IEEE_MODE && S1.d == sNaN)
D.d = Quiet(S1.d);
else if (S0.d == NaN)
D.d = S1.d;
else if (S1.d == NaN)
D.d = S0.d;
else if (S0.d == +0.0 && S1.d == -0.0)
D.d = S1.d;
else if (S0.d == -0.0 && S1.d == +0.0)
D.d = S0.d;
else
D.d = (S0.d < S1.d ? S0.d : S1.d);
endif.
```
https://github.com/llvm/llvm-project/pull/83158
More information about the libc-commits
mailing list