[llvm] [SelectionDAG] Remove UnsafeFPMath check in `visitFADDForFMACombine` (PR #127770)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 24 01:25:17 PDT 2025
================
@@ -17855,11 +17856,17 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
}
// FIXME: use fast math flags instead of Options.UnsafeFPMath
- if (Options.UnsafeFPMath) {
- if (N0CFP && N0CFP->isZero())
- return N2;
- if (N1CFP && N1CFP->isZero())
- return N2;
+ // TODO: Finally migrate away from global TargetOptions.
+ if (Options.AllowFPOpFusion == FPOpFusion::Fast ||
+ (Options.NoNaNsFPMath && Options.NoInfsFPMath) ||
+ (N->getFlags().hasNoNaNs() && N->getFlags().hasNoInfs())) {
+ if (Options.NoSignedZerosFPMath || N->getFlags().hasNoSignedZeros() ||
+ (N2CFP && !N2CFP->isExactlyValue(-0.0))) {
----------------
paperchalice wrote:
Add a simple test for X86
Finally we should merge it into `SelectionDAG::foldConstantFPMath` when it support unary and ternary operators.
https://github.com/llvm/llvm-project/pull/127770
More information about the llvm-commits
mailing list