Floating-point comparisons in the middle-end
FX
fxcoudert@gmail.com
Thu Sep 1 10:06:14 GMT 2022
Hi,
> Dunno if we really need a builtin for this, especially if it is lowered
> to that x >= y && x <= y early, will defer to Joseph.
I think it’d be nice to have one for consistency, as the other standard floating-point functions are there. It would also make things slightly easier for our Fortran implementation, although admittedly we can do without.
A tentative patch is attached, it seems to work well on simple examples, but for test coverage the hard part is going to be that the comparisons seem to be optimised away very easily into their non-signaling versions. Basically, if I do:
float x = __builtin_nanf("");
printf("%d\n", __builtin_iseqsig(__builtin_nanf(""), __builtin_inff()));
printf("%d\n", __builtin_iseqsig(x, __builtin_inff()));
With -O0 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans: first one does not raise invalid, second one does.
With -O2 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans: no invalid raised at all.
FX
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iseqsig.diff
Type: application/octet-stream
Size: 4360 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/fortran/attachments/20220901/a90aa573/attachment.obj>
More information about the Fortran
mailing list