summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-07-28 23:28:22 +0000
committerSanjay Patel <spatel@rotateright.com>2015-07-28 23:28:22 +0000
commit133e68b45cea9fa52c9a519bf287c6eea8ed5bba (patch)
tree76cf6d7c85229f6eb2891fccbf0c061896302d82 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent99a47ef90edb97b15becd553b1c9c5d76b9da376 (diff)
downloadbcm5719-llvm-133e68b45cea9fa52c9a519bf287c6eea8ed5bba.tar.gz
bcm5719-llvm-133e68b45cea9fa52c9a519bf287c6eea8ed5bba.zip
ignore duplicate divisor uses when transforming into reciprocal multiplies (PR24141)
PR24141: https://llvm.org/bugs/show_bug.cgi?id=24141 contains a test case where we have duplicate entries in a node's uses() list. After r241826, we use CombineTo() to delete dead nodes when combining the uses into reciprocal multiplies, but this fails if we encounter the just-deleted node again in the list. The solution in this patch is to not add duplicate entries to the list of users that we will subsequently iterate over. For the test case, this avoids triggering the combine divisors logic entirely because there really is only one user of the divisor. Differential Revision: http://reviews.llvm.org/D11345 llvm-svn: 243500
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index de2651650ef..3fe663630d5 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8261,11 +8261,11 @@ SDValue DAGCombiner::combineRepeatedFPDivisors(SDNode *N) {
return SDValue();
// Find all FDIV users of the same divisor.
- SmallVector<SDNode *, 4> Users;
- for (auto *U : N1->uses()) {
+ // Use a set because duplicates may be present in the user list.
+ SetVector<SDNode *> Users;
+ for (auto *U : N1->uses())
if (U->getOpcode() == ISD::FDIV && U->getOperand(1) == N1)
- Users.push_back(U);
- }
+ Users.insert(U);
// Now that we have the actual number of divisor uses, make sure it meets
// the minimum threshold specified by the target.
OpenPOWER on IntegriCloud