[llvm] [InstSimplify] Optimize maximumnum and minimumnum (PR #139581)
Lewis Crawford via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 06:58:26 PDT 2025
================
@@ -6741,15 +6741,14 @@ Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
// minnum(x, qnan) -> x
// maxnum(x, qnan) -> x
- // minnum(x, snan) -> qnan
- // maxnum(x, snan) -> qnan
+ // minnum(x, snan) -> qnan (or x for vectors mixing snans and qnans)
+ // maxnum(x, snan) -> qnan (or x for vectors mixing snans and qnans)
----------------
LewisCrawford wrote:
As far as I can tell, this is still legal (if slightly surprising) behaviour because of this wording in the spec:
> Floating-point math operations are allowed to treat all NaNs as if they were quiet NaNs. For example, “pow(1.0, SNaN)” may be simplified to 1.0.
What would your preferred behaviour here be for the <sNaN, qNaN> case and <sNaN, poison> case? The way the langref states it, it seems like the preferred approach is to sacrifice sNaN correctness any time it allows an optimization (and only try to preserve it when using StrictFP or constrained FP intrinsics).
https://github.com/llvm/llvm-project/pull/139581
More information about the llvm-commits
mailing list