diff options
author | Andrew Trick <atrick@apple.com> | 2012-01-06 21:41:55 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-01-06 21:41:55 +0000 |
commit | 260bf5364e151754c16f723d62c4080009bf98cb (patch) | |
tree | ac469e3299710e5263e46d3398cbdc711bf0d57e | |
parent | 59ecaae7b61ef0023ed1db4643937f7a57f61d10 (diff) | |
download | external_llvm-260bf5364e151754c16f723d62c4080009bf98cb.zip external_llvm-260bf5364e151754c16f723d62c4080009bf98cb.tar.gz external_llvm-260bf5364e151754c16f723d62c4080009bf98cb.tar.bz2 |
Put all IVUsers in the processed set. Allow querying IVUsers with isIVUserOrOperand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147686 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Analysis/IVUsers.h | 4 | ||||
-rw-r--r-- | lib/Analysis/IVUsers.cpp | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/include/llvm/Analysis/IVUsers.h b/include/llvm/Analysis/IVUsers.h index 2fb607c..2a3bb9b 100644 --- a/include/llvm/Analysis/IVUsers.h +++ b/include/llvm/Analysis/IVUsers.h @@ -166,6 +166,10 @@ public: const_iterator end() const { return IVUses.end(); } bool empty() const { return IVUses.empty(); } + bool isIVUserOrOperand(Instruction *Inst) const { + return Processed.count(Inst); + } + void print(raw_ostream &OS, const Module* = 0) const; /// dump - This method is used for debugging. diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp index d0ca892..cad22f8 100644 --- a/lib/Analysis/IVUsers.cpp +++ b/lib/Analysis/IVUsers.cpp @@ -83,6 +83,11 @@ static bool isInteresting(const SCEV *S, const Instruction *I, const Loop *L, /// reducible SCEV, recursively add its users to the IVUsesByStride set and /// return true. Otherwise, return false. bool IVUsers::AddUsersIfInteresting(Instruction *I) { + // 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)) + return true; // Instruction already handled. + if (!SE->isSCEVable(I->getType())) return false; // Void and FP expressions cannot be reduced. @@ -93,9 +98,6 @@ bool IVUsers::AddUsersIfInteresting(Instruction *I) { if (Width > 64 || (TD && !TD->isLegalInteger(Width))) return false; - if (!Processed.insert(I)) - return true; // Instruction already handled. - // Get the symbolic expression for this instruction. const SCEV *ISE = SE->getSCEV(I); @@ -268,6 +270,7 @@ void IVStrideUse::transformToPostInc(const Loop *L) { void IVStrideUse::deleted() { // Remove this user from the list. + Parent->Processed.erase(this->getUser()); Parent->IVUses.erase(this); // this now dangles! } |