From: Chris Lattner Date: Tue, 16 Aug 2005 00:38:11 +0000 (+0000) Subject: Fix a bad case in gzip where we put lots of things in registers across the X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=80b32b3aab369534a25cfab6d9b7447cc4a8ff1d;p=oota-llvm.git Fix a bad case in gzip where we put lots of things in registers across the loop, because a IV-dependent value was used outside of the loop and didn't have immediate-folding capability git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22798 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 9143f56d4d7..e97e0911c17 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -737,15 +737,23 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride, // fields of the BasedUsers. We do this so that it increases the commonality // of the remaining uses. for (unsigned i = 0, e = UsersToProcess.size(); i != e; ++i) { - // Addressing modes can be folded into loads and stores. Be careful that - // the store is through the expression, not of the expression though. - bool isAddress = isa(UsersToProcess[i].Inst); - if (StoreInst *SI = dyn_cast(UsersToProcess[i].Inst)) - if (SI->getOperand(1) == UsersToProcess[i].OperandValToReplace) - isAddress = true; - - MoveImmediateValues(UsersToProcess[i].Base, UsersToProcess[i].Imm, - isAddress, L); + // If the user is not in the current loop, this means it is using the exit + // value of the IV. Do not put anything in the base, make sure it's all in + // the immediate field to allow as much factoring as possible. + if (!L->contains(UsersToProcess[i].Inst->getParent())) { + std::swap(UsersToProcess[i].Base, UsersToProcess[i].Imm); + } else { + + // Addressing modes can be folded into loads and stores. Be careful that + // the store is through the expression, not of the expression though. + bool isAddress = isa(UsersToProcess[i].Inst); + if (StoreInst *SI = dyn_cast(UsersToProcess[i].Inst)) + if (SI->getOperand(1) == UsersToProcess[i].OperandValToReplace) + isAddress = true; + + MoveImmediateValues(UsersToProcess[i].Base, UsersToProcess[i].Imm, + isAddress, L); + } } // Now that we know what we need to do, insert the PHI node itself.