[PATCH] D60565: [LOOPINFO] Extend Loop object to add utilities to get the loop bounds, step, induction variable, and guard branch.

Whitney via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 13:35:18 PDT 2019


Whitney added inline comments.


================
Comment at: llvm/lib/Analysis/LoopInfo.cpp:294
+
+Direction Loop::LoopBounds::getDirection() const {
+  const SCEVAddRecExpr *StepAddRecExpr =
----------------
kbarton wrote:
> From what I have seen, a more common way to write this method in LLVM-style would be:
> 
>   if (SCEVAddRecExpr *StepAddRecExpr = dyn_cast<SCEVAddRecExpr>(SE.getSCEV(&getStepInst()))) 
>     if (const SCEV *StepRecur = StepAddRecExpr->getStepRecurrence(SE)) {
>       if (SE.isKnownPositive(StepRecur))
>         return Direction::Increasing;
>       if (SE.isKnownNegative(StepRecur))
>         return Direction::Decreasing;
>     }
>   return Direction::Unknown;
> 
> 
> That said, I don't know if this is explicitly documented anywhere. 
I thought they prefer early exit. https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60565/new/

https://reviews.llvm.org/D60565





More information about the llvm-commits mailing list