diff options
author | James Molloy <james.molloy@arm.com> | 2015-10-08 12:39:59 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2015-10-08 12:39:59 +0000 |
commit | bcd7f0ac9829fd3bae4ccdead15c40afd6957b4e (patch) | |
tree | 06e78652c03cf22c0cf3370374386e61d7d81a3a /llvm/lib/Analysis/DemandedBits.cpp | |
parent | ab9fdb922677a884a79854579204e3e8a06345c5 (diff) | |
download | bcm5719-llvm-bcd7f0ac9829fd3bae4ccdead15c40afd6957b4e.tar.gz bcm5719-llvm-bcd7f0ac9829fd3bae4ccdead15c40afd6957b4e.zip |
Treat Mul just like Add and Subtract
Like adds and subtracts, muls ripple only to the left so we can use
the same logic.
While we're here, add a print method to DemandedBits so it can be used
with -analyze, which we'll use in the testcase.
llvm-svn: 249686
Diffstat (limited to 'llvm/lib/Analysis/DemandedBits.cpp')
-rw-r--r-- | llvm/lib/Analysis/DemandedBits.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp index 775cbac4c53..6f92ba6289a 100644 --- a/llvm/lib/Analysis/DemandedBits.cpp +++ b/llvm/lib/Analysis/DemandedBits.cpp @@ -25,6 +25,7 @@ #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/BasicBlock.h" @@ -131,6 +132,7 @@ void DemandedBits::determineLiveOperandBits( break; case Instruction::Add: case Instruction::Sub: + case Instruction::Mul: // Find the highest live output bit. We don't need any more input // bits than that (adds, and thus subtracts, ripple only to the // left). @@ -368,6 +370,16 @@ bool DemandedBits::isInstructionDead(Instruction *I) { !isAlwaysLive(I); } +void DemandedBits::print(raw_ostream &OS, const Module *M) const { + // This is gross. But the alternative is making all the state mutable + // just because of this one debugging method. + const_cast<DemandedBits*>(this)->performAnalysis(); + for (auto &KV : AliveBits) { + OS << "DemandedBits: 0x" << utohexstr(KV.second.getLimitedValue()) << " for " + << *KV.first << "\n"; + } +} + FunctionPass *llvm::createDemandedBitsPass() { return new DemandedBits(); } |