diff options
author | Dale Johannesen <dalej@apple.com> | 2008-12-02 21:17:11 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2008-12-02 21:17:11 +0000 |
commit | fb10cd490195128d4d36ed9d963f173a6d6ca46e (patch) | |
tree | d653683dadaa0b3bb124300b3d9b33ecfb17be7d /lib | |
parent | 546d7b5c4a3cebf0d5017d42302b4a8d1c8ef584 (diff) |
Minor rewrite per review feedback.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 96ed932eda..5fa52df457 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -996,9 +996,14 @@ RemoveCommonExpressionsFromUseBases(std::vector<BasedUser> &Uses, // Otherwise, remove all of the CSE's we found from each of the base values. for (unsigned i = 0; i != NumUses; ++i) { - // For this purpose, consider only uses that are inside the loop. - if (!L->contains(Uses[i].Inst->getParent())) + // Uses outside the loop don't necessarily include the common base, but + // the final IV value coming into those uses does. Instead of trying to + // remove the pieces of the common base, which might not be there, + // subtract off the base to compensate for this. + if (!L->contains(Uses[i].Inst->getParent())) { + Uses[i].Base = SE->getMinusSCEV(Uses[i].Base, Result); continue; + } // Split the expression into subexprs. SeparateSubExprs(SubExprs, Uses[i].Base, SE); @@ -1476,12 +1481,6 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride, // Add BaseV to the PHI value if needed. RewriteExpr = SE->getAddExpr(RewriteExpr, SE->getUnknown(BaseV)); - // If this reference is not in the loop and we have a Common base, - // that has been added into the induction variable and must be - // subtracted off here. - if (HaveCommonExprs && !L->contains(User.Inst->getParent())) - RewriteExpr = SE->getMinusSCEV(RewriteExpr, CommonExprs); - User.RewriteInstructionToUseNewBase(RewriteExpr, NewBasePt, Rewriter, L, this, DeadInsts); |