summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DemandedBits.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-07 18:03:36 +0000
committerNikita Popov <nikita.ppv@gmail.com>2019-01-07 18:03:36 +0000
commit353d92decb38bcb163f49178ae950a89ccca6f54 (patch)
tree65fd9d1667ac1a3bf323916399f510578ae8c618 /llvm/lib/Analysis/DemandedBits.cpp
parent0d05790030e0a99bf25bbc4f311c66d7362d13c5 (diff)
downloadbcm5719-llvm-353d92decb38bcb163f49178ae950a89ccca6f54.tar.gz
bcm5719-llvm-353d92decb38bcb163f49178ae950a89ccca6f54.zip
[DemandedBits] Use SetVector for Worklist
DemandedBits currently uses a simple vector for the worklist, which means that instructions may be inserted multiple times into it. Especially in combination with the deep lattice, this may cause instructions too be recomputed very often. To avoid this, switch to a SetVector. Differential Revision: https://reviews.llvm.org/D56362 llvm-svn: 350547
Diffstat (limited to 'llvm/lib/Analysis/DemandedBits.cpp')
-rw-r--r--llvm/lib/Analysis/DemandedBits.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp
index ba310d8d321..016399ff592 100644
--- a/llvm/lib/Analysis/DemandedBits.cpp
+++ b/llvm/lib/Analysis/DemandedBits.cpp
@@ -21,8 +21,7 @@
#include "llvm/Analysis/DemandedBits.h"
#include "llvm/ADT/APInt.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/ValueTracking.h"
@@ -315,7 +314,7 @@ void DemandedBits::performAnalysis() {
AliveBits.clear();
DeadUses.clear();
- SmallVector<Instruction*, 128> Worklist;
+ SmallSetVector<Instruction*, 128> Worklist;
// Collect the set of "root" instructions that are known live.
for (Instruction &I : instructions(F)) {
@@ -330,7 +329,7 @@ void DemandedBits::performAnalysis() {
Type *T = I.getType();
if (T->isIntOrIntVectorTy()) {
if (AliveBits.try_emplace(&I, T->getScalarSizeInBits(), 0).second)
- Worklist.push_back(&I);
+ Worklist.insert(&I);
continue;
}
@@ -341,7 +340,7 @@ void DemandedBits::performAnalysis() {
Type *T = J->getType();
if (T->isIntOrIntVectorTy())
AliveBits[J] = APInt::getAllOnesValue(T->getScalarSizeInBits());
- Worklist.push_back(J);
+ Worklist.insert(J);
}
}
// To save memory, we don't add I to the Visited set here. Instead, we
@@ -412,11 +411,11 @@ void DemandedBits::performAnalysis() {
APInt ABNew = AB | ABPrev;
if (ABNew != ABPrev || ABI == AliveBits.end()) {
AliveBits[I] = std::move(ABNew);
- Worklist.push_back(I);
+ Worklist.insert(I);
}
}
} else if (I && !Visited.count(I)) {
- Worklist.push_back(I);
+ Worklist.insert(I);
}
}
}
OpenPOWER on IntegriCloud