diff options
author | Andrew Trick <atrick@apple.com> | 2012-03-22 17:47:33 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-03-22 17:47:33 +0000 |
commit | 1508e5e0495a3b3d034cb8e0b9be16b01749d8b3 (patch) | |
tree | cbec739ad767227e2e8773aac9465ecc3a4359ca | |
parent | 9f2539507c954e35a6e845c0665a2fcdb07faad1 (diff) | |
download | external_llvm-1508e5e0495a3b3d034cb8e0b9be16b01749d8b3.zip external_llvm-1508e5e0495a3b3d034cb8e0b9be16b01749d8b3.tar.gz external_llvm-1508e5e0495a3b3d034cb8e0b9be16b01749d8b3.tar.bz2 |
Cleanup IVUsers::addUsersIfInteresting.
Keep the public interface clean, even though LLVM proper does not
currently use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153263 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Analysis/IVUsers.h | 5 | ||||
-rw-r--r-- | lib/Analysis/IVUsers.cpp | 27 |
2 files changed, 18 insertions, 14 deletions
diff --git a/include/llvm/Analysis/IVUsers.h b/include/llvm/Analysis/IVUsers.h index 11d2cf0..2bf79b9 100644 --- a/include/llvm/Analysis/IVUsers.h +++ b/include/llvm/Analysis/IVUsers.h @@ -145,8 +145,7 @@ public: /// AddUsersIfInteresting - Inspect the specified Instruction. If it is a /// reducible SCEV, recursively add its users to the IVUsesByStride set and /// return true. Otherwise, return false. - bool AddUsersIfInteresting(Instruction *I, - SmallPtrSet<Loop*,16> &SimpleLoopNests); + bool AddUsersIfInteresting(Instruction *I); IVStrideUse &AddUser(Instruction *User, Value *Operand); @@ -175,6 +174,8 @@ public: /// dump - This method is used for debugging. void dump() const; +protected: + bool AddUsersImpl(Instruction *I, SmallPtrSet<Loop*,16> &SimpleLoopNests); }; Pass *createIVUsersPass(); diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp index 463584d..b80966b 100644 --- a/lib/Analysis/IVUsers.cpp +++ b/lib/Analysis/IVUsers.cpp @@ -107,11 +107,11 @@ static bool isSimplifiedLoopNest(BasicBlock *BB, const DominatorTree *DT, return true; } -/// AddUsersIfInteresting - Inspect the specified instruction. If it is a +/// AddUsersImpl - Inspect the specified instruction. If it is a /// reducible SCEV, recursively add its users to the IVUsesByStride set and /// return true. Otherwise, return false. -bool IVUsers::AddUsersIfInteresting(Instruction *I, - SmallPtrSet<Loop*,16> &SimpleLoopNests) { +bool IVUsers::AddUsersImpl(Instruction *I, + SmallPtrSet<Loop*,16> &SimpleLoopNests) { // Add this IV user to the Processed set before returning false to ensure that // all IV users are members of the set. See IVUsers::isIVUserOrOperand. if (!Processed.insert(I)) @@ -167,13 +167,12 @@ bool IVUsers::AddUsersIfInteresting(Instruction *I, bool AddUserToIVUsers = false; if (LI->getLoopFor(User->getParent()) != L) { if (isa<PHINode>(User) || Processed.count(User) || - !AddUsersIfInteresting(User, SimpleLoopNests)) { + !AddUsersImpl(User, SimpleLoopNests)) { DEBUG(dbgs() << "FOUND USER in other loop: " << *User << '\n' << " OF SCEV: " << *ISE << '\n'); AddUserToIVUsers = true; } - } else if (Processed.count(User) - || !AddUsersIfInteresting(User, SimpleLoopNests)) { + } else if (Processed.count(User) || !AddUsersImpl(User, SimpleLoopNests)) { DEBUG(dbgs() << "FOUND USER: " << *User << '\n' << " OF SCEV: " << *ISE << '\n'); AddUserToIVUsers = true; @@ -197,6 +196,15 @@ bool IVUsers::AddUsersIfInteresting(Instruction *I, return true; } +bool IVUsers::AddUsersIfInteresting(Instruction *I) { + // SCEVExpander can only handle users that are dominated by simplified loop + // entries. Keep track of all loops that are only dominated by other simple + // loops so we don't traverse the domtree for each user. + SmallPtrSet<Loop*,16> SimpleLoopNests; + + return AddUsersImpl(I, SimpleLoopNests); +} + IVStrideUse &IVUsers::AddUser(Instruction *User, Value *Operand) { IVUses.push_back(new IVStrideUse(this, User, Operand)); return IVUses.back(); @@ -222,16 +230,11 @@ bool IVUsers::runOnLoop(Loop *l, LPPassManager &LPM) { SE = &getAnalysis<ScalarEvolution>(); TD = getAnalysisIfAvailable<TargetData>(); - // SCEVExpander can only handle users that are dominated by simplified loop - // entries. Keep track of all loops that are only dominated by other simple - // loops so we don't traverse the domtree for each user. - SmallPtrSet<Loop*,16> SimpleLoopNests; - // Find all uses of induction variables in this loop, and categorize // them by stride. Start by finding all of the PHI nodes in the header for // this loop. If they are induction variables, inspect their uses. for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ++I) - (void)AddUsersIfInteresting(I, SimpleLoopNests); + (void)AddUsersIfInteresting(I); return false; } |