Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM, though a second read from someone familiar with floating point is probably warranted.
fadd and fmul are clearly okay.
Reading the RISCV specification, the FEQ case appears okay. The FMIN and FMAX cases give me the most pause, but the description seems to be commutative.
As mentioned in spec, For the purposes of these instructions only, the value −0.0 is considered to be less than the value +0.0
I think FMIN & FMAX is commutative.
LGTM.
For some additional detail.
In C++, std::max of 2 FP numbers is not commutable but std::fmax is commutable. std::max is implemented as something like a > b ? a : b which returns b when a or b is a nan since relative comparisons return false if either input is a nan. std::fmax on the other hand returns the non-nan input unless both inputs are nan.
RISCV's implementation of FMAX/FMIN is similar to std::fmax (though there is a difference for snan). X86 SSE on the other hand implement FP max/min instructions that are closer to std::max. For X86, we allowed max/min to be commuted under fast math using CodeGenOnly instructions.