Skip to content

Commit b1be480

Browse files
committed
[DAGCombiner] Move CanReassociate down to first use. NFC.
1 parent 51e459a commit b1be480

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15816,8 +15816,6 @@ SDValue DAGCombiner::visitFADDForFMACombine(SDNode *N) {
1581615816
if (!HasFMAD && !HasFMA)
1581715817
return SDValue();
1581815818

15819-
bool CanReassociate =
15820-
Options.UnsafeFPMath || N->getFlags().hasAllowReassociation();
1582115819
bool AllowFusionGlobally = (Options.AllowFPOpFusion == FPOpFusion::Fast ||
1582215820
Options.UnsafeFPMath || HasFMAD);
1582315821
// If the addition is not contractable, do not combine.
@@ -15877,6 +15875,8 @@ SDValue DAGCombiner::visitFADDForFMACombine(SDNode *N) {
1587715875
// fadd (G, (fma A, B, (fma (C, D, (fmul (E, F)))))) -->
1587815876
// fma A, B, (fma C, D, fma (E, F, G)).
1587915877
// This requires reassociation because it changes the order of operations.
15878+
bool CanReassociate =
15879+
Options.UnsafeFPMath || N->getFlags().hasAllowReassociation();
1588015880
if (CanReassociate) {
1588115881
SDValue FMA, E;
1588215882
if (isFusedOp(N0) && N0.hasOneUse()) {
@@ -17033,9 +17033,6 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
1703317033
SelectionDAG::FlagInserter FlagsInserter(DAG, N);
1703417034
MatchContextClass matcher(DAG, TLI, N);
1703517035

17036-
bool CanReassociate =
17037-
Options.UnsafeFPMath || N->getFlags().hasAllowReassociation();
17038-
1703917036
// Constant fold FMA.
1704017037
if (isa<ConstantFPSDNode>(N0) &&
1704117038
isa<ConstantFPSDNode>(N1) &&
@@ -17078,6 +17075,8 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
1707817075
!DAG.isConstantFPBuildVectorOrConstantFP(N1))
1707917076
return matcher.getNode(ISD::FMA, SDLoc(N), VT, N1, N0, N2);
1708017077

17078+
bool CanReassociate =
17079+
Options.UnsafeFPMath || N->getFlags().hasAllowReassociation();
1708117080
if (CanReassociate) {
1708217081
// (fma x, c1, (fmul x, c2)) -> (fmul x, c1+c2)
1708317082
if (matcher.match(N2, ISD::FMUL) && N0 == N2.getOperand(0) &&

0 commit comments

Comments
 (0)