Hi Jim,
> The flto/etc instructions you mentioned are for unordered/ordered
compares
> and we can easily emulate those with a few extra instructions.
I think "total order" is a misleading name as it sounds as if it was related to unordered/ordered comparisons, but it really isn't.
> If that is all you need, then you can already compute totalorder using
the existing instructions.
> It will just require more instructions than
necessary if we had a full set of FP compare operations.
> Also see the
fclass instruction which solves the other half of the problem.
I'm not sure this is possible, as unordered/ordered comparisons indiscriminately put NaNs first/last,
and I'm also pretty sure they treat 0.0 and -0.0 as equal (The total order is specified as the following: -qNaN
-sNaN
-Inf
-1024.0 -1.0
-0.0
0.0
1.0
1024.0
Inf sNaN qNaN.)
The only implementations I have ever seen do not use floating point comparisons, but move the float to gp registers and do bit shifts and integer comparisons there.
I would really like to see an example of a set of instructions that operates only the f register.
If it was possible, I would imagine it would take a lot of branches to make float comparisons do float ordering that it would be so exceedingly expensive that moving floats to gp registers would be cheaper.
(The code shown is branch-free up to the point of the integer comparison at the end.)
> RISC-V does support
all of the comparison functions required by the IEEE FP standard.
> It
just requires more than one instruction to compute some of them.
This is kind of my motivation, as moves between x and f registers probably have a high variability between core designs, compared to an instruction that works on f registers directly.
Thanks,
Simon