[llvm] [SelectionDAG] Use FMAXNUM_IEEE/FMINNUM_IEEE for never-sNaN maximumNumber patterns (PR #196349)

Usha Gupta via llvm-commits llvm-commits at lists.llvm.org
Fri May 8 05:41:11 PDT 2026


usha1830 wrote:

> We should not be adding anything to this SDAGBuilder code. It has various correctness issues and is the wrong place to do this anyway.
> 
> If you want to do something like this, DAGCombine is the place.
> 
> Though I'll also say that the isKnownNeverSNaN() query this is based on is also incorrect, because it says that things like FADD are never sNaN, but fail to account for LLVM IR semantics which allow omission of canonicalizing operations. And I checked, this does happen on the SDAG level as well, see simplifyFPBinop, which will happily fold `(fadd x, -0.0)` to `x`, where `x` certainly can be sNaN.

@nikic 
Thanks, that makes sense.
The intended optimization was relying on isKnownNeverSNaN() to justify replacing FMAXIMUMNUM/FMINIMUMNUM with FMAXNUM_IEEE/FMINNUM_IEEE, but your example from  simplifyFPBinop example shows that it is not sufficient

I will close this PR and look at a DAGCombine-based approach instead.


https://github.com/llvm/llvm-project/pull/196349


More information about the llvm-commits mailing list