[llvm] [SelectionDAG] Remove UnsafeFPMath check in `visitFADDForFMACombine` (PR #127770)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 24 09:27:19 PST 2025


andykaylor wrote:

> > Have you looked at what happens when you compile with -ffp-contract=fast-honor-pragmas? As mentioned at https://discourse.llvm.org/t/allowfpopfusion-vs-sdnodeflags-hasallowcontract/80909 I have seen some backends not generating FMA when that option is used, and I think this change could make it worse in the case of options like `-funsafe-math-optimizations -ffp-contract=fast-honor-pragmas`.
> 
> Didn't check with clang but llc with option `-fp=contract=fast`, for the 4th example in link now can generate fma instruction.

My concern was that with `-ffp-contract=fast-honor-pragmas` on the command-line, clang sets `AllowOpFusion` to `FPOpFusion::Standard` not `FPOpFusion::Fast`. This is happening specifically because the backend was fusing operations where `contract` wasn't set because of a pragma.

Looking again at the first case you modified in DAGCombiner, I see that it is checking the node flag immediately after the check that you modified, so that is the desired behavior, but the second case doesn't appear to check the node FMF and, in fact, has a FIXME comment saying that it should.

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


More information about the llvm-commits mailing list