summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DemandedBits.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/DemandedBits.cpp')
-rw-r--r--llvm/lib/Analysis/DemandedBits.cpp47
1 files changed, 6 insertions, 41 deletions
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp
index fcc2fd8962c..0382787fbef 100644
--- a/llvm/lib/Analysis/DemandedBits.cpp
+++ b/llvm/lib/Analysis/DemandedBits.cpp
@@ -314,7 +314,6 @@ void DemandedBits::performAnalysis() {
Visited.clear();
AliveBits.clear();
- DeadUses.clear();
SmallVector<Instruction*, 128> Worklist;
@@ -375,35 +374,26 @@ void DemandedBits::performAnalysis() {
Type *T = I->getType();
if (T->isIntOrIntVectorTy()) {
unsigned BitWidth = T->getScalarSizeInBits();
-
- // Previous demanded bits information for this use.
- APInt ABPrev(BitWidth, 0);
- auto ABI = AliveBits.find(I);
- if (ABI != AliveBits.end())
- ABPrev = ABI->second;
-
APInt AB = APInt::getAllOnesValue(BitWidth);
if (UserI->getType()->isIntOrIntVectorTy() && !AOut &&
!isAlwaysLive(UserI)) {
- // If all bits of the output are dead, then all bits of the input
- // are also dead.
AB = APInt(BitWidth, 0);
} else {
+ // If all bits of the output are dead, then all bits of the input
// Bits of each operand that are used to compute alive bits of the
// output are alive, all others are dead.
determineLiveOperandBits(UserI, I, OI.getOperandNo(), AOut, AB,
Known, Known2);
-
- // Keep track of uses which have no demanded bits.
- if (AB.isNullValue())
- DeadUses.insert(&OI);
- else if (ABPrev.isNullValue())
- DeadUses.erase(&OI);
}
// If we've added to the set of alive bits (or the operand has not
// been previously visited), then re-queue the operand to be visited
// again.
+ APInt ABPrev(BitWidth, 0);
+ auto ABI = AliveBits.find(I);
+ if (ABI != AliveBits.end())
+ ABPrev = ABI->second;
+
APInt ABNew = AB | ABPrev;
if (ABNew != ABPrev || ABI == AliveBits.end()) {
AliveBits[I] = std::move(ABNew);
@@ -436,31 +426,6 @@ bool DemandedBits::isInstructionDead(Instruction *I) {
!isAlwaysLive(I);
}
-bool DemandedBits::isUseDead(Use *U) {
- // We only track integer uses, everything else is assumed live.
- if (!(*U)->getType()->isIntOrIntVectorTy())
- return false;
-
- // Uses by always-live instructions are never dead.
- Instruction *UserI = cast<Instruction>(U->getUser());
- if (isAlwaysLive(UserI))
- return false;
-
- performAnalysis();
- if (DeadUses.count(U))
- return true;
-
- // If no output bits are demanded, no input bits are demanded and the use
- // is dead. These uses might not be explicitly present in the DeadUses map.
- if (UserI->getType()->isIntOrIntVectorTy()) {
- auto Found = AliveBits.find(UserI);
- if (Found != AliveBits.end() && Found->second.isNullValue())
- return true;
- }
-
- return false;
-}
-
void DemandedBits::print(raw_ostream &OS) {
performAnalysis();
for (auto &KV : AliveBits) {
OpenPOWER on IntegriCloud