[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
Thu Apr 11 17:14:39 PDT 2019


Whitney marked 4 inline comments as done.
Whitney added inline comments.


================
Comment at: llvm/include/llvm/Analysis/LoopInfo.h:620
+
+  /// Return the loop induction variable if found, else return nullptr.
+  /// An instruction is considered as induction variable if
----------------
jdoerfert wrote:
> Whitney wrote:
> > jdoerfert wrote:
> > > "The" loop induction variable, or "any" loop induction variable. There could easily be two or more.
> > In this context, loop induction variable is defined as the the phi node in the loop header which is used in the condition of the conditional branch in the loop latch, so should only be one.
> ```
> for (i = 0, j = N; i < j; i++,j--)
>   body(i,j);
> ```
That's true. I edited the function description to specify that the loop induction variable is expected to be used as the LHS of the conditional branch in the loop latch.


================
Comment at: llvm/include/llvm/Analysis/LoopInfo.h:635
+  bool isAuxiliaryInductionVariable(PHINode &AuxIndVar,
+                                    ScalarEvolution *SE = nullptr) const;
+
----------------
jdoerfert wrote:
> Whitney wrote:
> > jdoerfert wrote:
> > > Why is it called auxiliary and what happens if you call it with the only induction variable?
> > Auxiliary induction variable doesn't require to be used in the loop latch condition.
> Can you mention that and thereby make it explicit. 
Good idea, edited the function description. 


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