summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-07-28 23:05:48 +0000
committerSanjay Patel <spatel@rotateright.com>2015-07-28 23:05:48 +0000
commit1dd15598cf6ca4338509c90ec2f93957ba3ee229 (patch)
treec4d24325d9d450c5ed6d31434ed086ca6bc59b85 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentef5c196fb04820c808b70288d58a9eca423091b1 (diff)
downloadbcm5719-llvm-1dd15598cf6ca4338509c90ec2f93957ba3ee229.tar.gz
bcm5719-llvm-1dd15598cf6ca4338509c90ec2f93957ba3ee229.zip
fix TLI's combineRepeatedFPDivisors interface to return the minimum user threshold
This fix was suggested as part of D11345 and is part of fixing PR24141. With this change, we can avoid walking the uses of a divisor node if the target doesn't want the combineRepeatedFPDivisors transform in the first place. There is no NFC-intended other than that. Differential Revision: http://reviews.llvm.org/D11531 llvm-svn: 243498
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index b06d53310bb..de2651650ef 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8247,23 +8247,29 @@ SDValue DAGCombiner::combineRepeatedFPDivisors(SDNode *N) {
if (!DAG.getTarget().Options.UnsafeFPMath)
return SDValue();
+ // Skip if current node is a reciprocal.
SDValue N0 = N->getOperand(0);
ConstantFPSDNode *N0CFP = dyn_cast<ConstantFPSDNode>(N0);
-
- // Skip if current node is a reciprocal.
if (N0CFP && N0CFP->isExactlyValue(1.0))
return SDValue();
+ // Exit early if the target does not want this transform or if there can't
+ // possibly be enough uses of the divisor to make the transform worthwhile.
SDValue N1 = N->getOperand(1);
- SmallVector<SDNode *, 4> Users;
+ unsigned MinUses = TLI.combineRepeatedFPDivisors();
+ if (!MinUses || N1->use_size() < MinUses)
+ return SDValue();
// Find all FDIV users of the same divisor.
+ SmallVector<SDNode *, 4> Users;
for (auto *U : N1->uses()) {
if (U->getOpcode() == ISD::FDIV && U->getOperand(1) == N1)
Users.push_back(U);
}
- if (!TLI.combineRepeatedFPDivisors(Users.size()))
+ // Now that we have the actual number of divisor uses, make sure it meets
+ // the minimum threshold specified by the target.
+ if (Users.size() < MinUses)
return SDValue();
EVT VT = N->getValueType(0);
OpenPOWER on IntegriCloud