These new intrinsics have the semantics of the minimum and maximum
operations specified by the latest draft of IEEE 754-2018. Unlike
llvm.minnum and llvm.maxnum, these new intrinsics propagate NaNs and
always treat -0.0 as less than 0.0. minimum and maximum lower
directly to the existing fminnan and fmaxnan ISel DAG nodes. It is
safe to reuse these DAG nodes because before this patch were only
emitted in situations where there were known to be no NaN arguments or
where NaN propagation was correct and there were known to be no zero
arguments. I know of only four backends that lower fminnan and
fmaxnan: WebAssembly, ARM, AArch64, and SystemZ, and each of these
lowers fminnan and fmaxnan to instructions that are compatible with
the IEEE 754-2018 semantics.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
docs/LangRef.rst | ||
---|---|---|
11638 ↗ | (On Diff #167874) | Does this need a para on sNaN and qNaN behaviour (as above for llvm.max) ? |
docs/LangRef.rst | ||
---|---|---|
11638 ↗ | (On Diff #167874) | I don't think so. llvm.maxnum and llvm.minnum need that paragraph because backends may have the unusual responsibility to quiet input NaNs for those operations in order to match the intrinsic semantics. That is because the minNum and maxNum in IEEE 754-2008 are exceptional in their handling of sNaNs and qNaNs. In contrast, these new intrinsics have the standard NaN propagation behavior for both sNaNs and qNaNs. Backends shouldn't need to take any additional action to canonicalize NaNs to get the right results. |
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
5588 ↗ | (On Diff #167874) | Either as a dependency or an after-step, I think the DAG nodes should be renamed to match the intrinsic |
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
5588 ↗ | (On Diff #167874) | I'd be happy to do this in a follow-on. This makes sense to me because the names minnan and maxnan imply that the only difference from minnum and maxnum is NaN propagation, which is not correct. |
Bit of formatting nits
docs/LangRef.rst | ||
---|---|---|
11564 ↗ | (On Diff #167874) | One more ^ at the end |
11602 ↗ | (On Diff #167874) | One more ^ at the end |
11613 ↗ | (On Diff #167874) |
|
11615 ↗ | (On Diff #167874) | double whitespaces between x86_fp80 and %Val0 / x86_fp80 and %Val1 |
11617 ↗ | (On Diff #167874) | double whitespaces between ppc_fp128 and %Val0 / ppc_fp128 and %Val1 |