[PATCH] D54007: Use a data structure better suited for large sets in SimplificationTracker.
Ali Tamur via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 1 15:14:04 PDT 2018
tamur created this revision.
tamur added reviewers: bjope, skatkov.
Herald added a subscriber: llvm-commits.
https://reviews.llvm.org/D44571 changed SimplificationTracker to use SmallSetVector to keep phi nodes. As a result, when the number of phi nodes is large, the build time performance suffers badly. When building for power pc, we have a case where there are more than 600.000 nodes, and it takes too long to compile.
In this change, I partially revert https://reviews.llvm.org/D44571 to use SmallPtrSet, which does an acceptable job with any number of elements. In the original patch, having a deterministic iteration order was mentioned as a motivation, however I think it only applies to the nodes already matched in MatchPhiSet method, which I did not touch.
Repository:
rL LLVM
https://reviews.llvm.org/D54007
Files:
lib/CodeGen/CodeGenPrepare.cpp
Index: lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- lib/CodeGen/CodeGenPrepare.cpp
+++ lib/CodeGen/CodeGenPrepare.cpp
@@ -2650,7 +2650,7 @@
const SimplifyQuery &SQ;
// Tracks newly created Phi nodes. We use a SetVector to get deterministic
// order when iterating over the set in MatchPhiSet.
- SmallSetVector<PHINode *, 32> AllPhiNodes;
+ SmallPtrSet<PHINode *, 32> AllPhiNodes;
// Tracks newly created Select nodes.
SmallPtrSet<SelectInst *, 32> AllSelectNodes;
@@ -2682,7 +2682,7 @@
Put(PI, V);
PI->replaceAllUsesWith(V);
if (auto *PHI = dyn_cast<PHINode>(PI))
- AllPhiNodes.remove(PHI);
+ AllPhiNodes.erase(PHI);
if (auto *Select = dyn_cast<SelectInst>(PI))
AllSelectNodes.erase(Select);
PI->eraseFromParent();
@@ -2705,11 +2705,11 @@
assert(Get(To) == To && "Replacement PHI node is already replaced.");
Put(From, To);
From->replaceAllUsesWith(To);
- AllPhiNodes.remove(From);
+ AllPhiNodes.erase(From);
From->eraseFromParent();
}
- SmallSetVector<PHINode *, 32>& newPhiNodes() { return AllPhiNodes; }
+ SmallPtrSet<PHINode *, 32>& newPhiNodes() { return AllPhiNodes; }
void insertNewPhi(PHINode *PN) { AllPhiNodes.insert(PN); }
@@ -2954,7 +2954,7 @@
/// Matcher tracks the matched Phi nodes.
bool MatchPhiNode(PHINode *PHI, PHINode *Candidate,
SmallSetVector<PHIPair, 8> &Matcher,
- SmallSetVector<PHINode *, 32> &PhiNodesToMatch) {
+ SmallPtrSet<PHINode *, 32> &PhiNodesToMatch) {
SmallVector<PHIPair, 8> WorkList;
Matcher.insert({ PHI, Candidate });
WorkList.push_back({ PHI, Candidate });
@@ -3007,7 +3007,7 @@
// in a deterministic order below.
SmallSetVector<PHIPair, 8> Matched;
SmallPtrSet<PHINode *, 8> WillNotMatch;
- SmallSetVector<PHINode *, 32> &PhiNodesToMatch = ST.newPhiNodes();
+ SmallPtrSet<PHINode *, 32> &PhiNodesToMatch = ST.newPhiNodes();
while (PhiNodesToMatch.size()) {
PHINode *PHI = *PhiNodesToMatch.begin();
@@ -3042,7 +3042,7 @@
// Just remove all seen values in matcher. They will not match anything.
PhiNotMatchedCount += WillNotMatch.size();
for (auto *P : WillNotMatch)
- PhiNodesToMatch.remove(P);
+ PhiNodesToMatch.erase(P);
}
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54007.172249.patch
Type: text/x-patch
Size: 2451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181101/22d8ec9e/attachment.bin>
More information about the llvm-commits
mailing list