[PATCH] D21237: LoopRotation: remove iterative calls to rotateLoops

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 10 12:37:56 PDT 2016


What's the reasoning/justification for the original vs the change?


On Fri, Jun 10, 2016 at 12:36 PM, Sebastian Pop <sebpop at gmail.com> wrote:

> sebpop created this revision.
> sebpop added reviewers: dberlin, atrick, hfinkel.
> sebpop added subscribers: llvm-commits, hiraditya.
> Herald added a subscriber: mzolotukhin.
>
> Loops should be rotated only once.  Passes regression test and llvm
> test-suite.
>
> Patch wrote by Aditya Kumar and Sebastian Pop.
>
> http://reviews.llvm.org/D21237
>
> Files:
>   llvm/lib/Transforms/Scalar/LoopRotation.cpp
>
> Index: llvm/lib/Transforms/Scalar/LoopRotation.cpp
> ===================================================================
> --- llvm/lib/Transforms/Scalar/LoopRotation.cpp
> +++ llvm/lib/Transforms/Scalar/LoopRotation.cpp
> @@ -569,9 +569,8 @@
>    return true;
>  }
>
> -/// Rotate \c L as many times as possible. Return true if the loop is
> rotated
> -/// at least once.
> -static bool iterativelyRotateLoop(Loop *L, unsigned MaxHeaderSize,
> LoopInfo *LI,
> +/// Rotate loop L.  Return true if the loop is rotated.
> +static bool rotateLoop(Loop *L, unsigned MaxHeaderSize, LoopInfo *LI,
>                                    const TargetTransformInfo *TTI,
>                                    AssumptionCache *AC, DominatorTree *DT,
>                                    ScalarEvolution *SE) {
> @@ -582,13 +581,8 @@
>    // upward. Rotation may not be needed if the loop tail can be folded
> into the
>    // loop exit.
>    bool SimplifiedLatch = simplifyLoopLatch(L, LI, DT);
> -
> -  // One loop can be rotated multiple times.
> -  bool MadeChange = false;
> -  while (rotateLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE,
> SimplifiedLatch)) {
> -    MadeChange = true;
> -    SimplifiedLatch = false;
> -  }
> +  bool MadeChange = rotateLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE,
> +                               SimplifiedLatch);
>
>    // Restore the loop metadata.
>    // NB! We presume LoopRotation DOESN'T ADD its own metadata.
> @@ -613,7 +607,7 @@
>    auto *DT = FAM.getCachedResult<DominatorTreeAnalysis>(*F);
>    auto *SE = FAM.getCachedResult<ScalarEvolutionAnalysis>(*F);
>
> -  bool Changed = iterativelyRotateLoop(&L, MaxHeaderSize, LI, TTI, AC,
> DT, SE);
> +  bool Changed = rotateLoop(&L, MaxHeaderSize, LI, TTI, AC, DT, SE);
>    if (!Changed)
>      return PreservedAnalyses::all();
>    return getLoopPassPreservedAnalyses();
> @@ -654,7 +648,7 @@
>      auto *SEWP = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>();
>      auto *SE = SEWP ? &SEWP->getSE() : nullptr;
>
> -    return iterativelyRotateLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE);
> +    return rotateLoop(L, MaxHeaderSize, LI, TTI, AC, DT, SE);
>    }
>  };
>  }
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160610/55f98df4/attachment.html>


More information about the llvm-commits mailing list