diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-03-06 21:58:22 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-03-06 21:58:22 +0000 |
| commit | d3874fad443468053baec92179fec3dd27dedcad (patch) | |
| tree | 966c75946c9c1e0907ff4aa64ccc1f76a6b9a272 /llvm/lib | |
| parent | 9cd727c2eeb15154654ce241c76530dd75823ee7 (diff) | |
| download | bcm5719-llvm-d3874fad443468053baec92179fec3dd27dedcad.tar.gz bcm5719-llvm-d3874fad443468053baec92179fec3dd27dedcad.zip | |
minor simplifications of the code.
llvm-svn: 20497
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 33ac4723a0a..7ba4b810955 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -35,16 +35,15 @@ using namespace llvm; namespace { Statistic<> NumReduced ("loop-reduce", "Number of GEPs strength reduced"); - class GEPCache - { + class GEPCache { public: GEPCache() : CachedPHINode(0), Map() {} - GEPCache* operator[](Value *v) { + GEPCache *get(Value *v) { std::map<Value *, GEPCache>::iterator I = Map.find(v); if (I == Map.end()) I = Map.insert(std::pair<Value *, GEPCache>(v, GEPCache())).first; - return &(I->second); + return &I->second; } PHINode *CachedPHINode; @@ -135,7 +134,7 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, BasicBlock *Header = L->getHeader(); BasicBlock *Preheader = L->getLoopPreheader(); bool AllConstantOperands = true; - Cache = (*Cache)[GEPI->getOperand(0)]; + Cache = Cache->get(GEPI->getOperand(0)); for (unsigned op = 1, e = GEPI->getNumOperands(); op != e; ++op) { Value *operand = GEPI->getOperand(op); @@ -164,7 +163,7 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, AllConstantOperands = false; } else return; - Cache = (*Cache)[operand]; + Cache = Cache->get(operand); } assert(indvar > 0 && "Indvar used by GEP not found in operand list"); @@ -179,8 +178,8 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, // Don't reduce multiplies that the target can handle via addressing modes. uint64_t sz = getAnalysis<TargetData>().getTypeSize(ty); - for (unsigned i = 1; i <= MaxTargetAMSize; i *= 2) - if (i == sz) + if (sz && (sz & (sz-1)) == 0) // Power of two? + if (sz <= (1ULL << (MaxTargetAMSize-1))) return; // If all operands of the GEP we are going to insert into the preheader @@ -248,7 +247,7 @@ void LoopStrengthReduce::strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, GEPI->getName() + ".lsr", GEPI); GEPI->replaceAllUsesWith(newGEP); -} + } // The old GEP is now dead. DeadInsts.insert(GEPI); |

