LSR: ignore strides in outer loops.
authorAndrew Trick <atrick@apple.com>
Sat, 10 Dec 2011 00:25:00 +0000 (00:25 +0000)
committerAndrew Trick <atrick@apple.com>
Sat, 10 Dec 2011 00:25:00 +0000 (00:25 +0000)
Since we're not rewriting IVs in other loops, there's not much reason
to consider their stride when generating formulae.
This should reduce the number of useless formulas considered by LSR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146302 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index 7867d9fad348ff1607db0d8d075b62988b81476b..ad2f52d8ec715ea8b32ee7c65d44d8403c92c9f9 100644 (file)
@@ -2061,7 +2061,8 @@ void LSRInstance::CollectInterestingTypesAndFactors() {
     do {
       const SCEV *S = Worklist.pop_back_val();
       if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) {
-        Strides.insert(AR->getStepRecurrence(SE));
+        if (EnableNested || AR->getLoop() == L)
+          Strides.insert(AR->getStepRecurrence(SE));
         Worklist.push_back(AR->getStart());
       } else if (const SCEVAddExpr *Add = dyn_cast<SCEVAddExpr>(S)) {
         Worklist.append(Add->op_begin(), Add->op_end());