[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 07:12:32 PDT 2019


Whitney created this revision.
Whitney added reviewers: kbarton, hfinkel, dmgreen, Meinersbur, jdoerfert, syzaara.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This PR extends the loop object with more utilities to get loop bounds, step, induction variable, and guard branch. There already exists passes which try to obtain the loop induction variable in their own pass, e.g. loop interchange. It would be useful to have a common area to get these information. Moreover, loop fusion (https://reviews.llvm.org/D55851) is planning to use getGuard() to extend the kind of loops it is able to fuse, e.g. rotated loop with non-constant upper bound, which would have a loop guard.

  /// Example:
  /// for (int i = lb; i < ub; i+=step)
  ///   <loop body>
  /// --- pseudo LLVMIR ---
  /// beforeloop:
  ///   guardcmp = (lb < ub)
  ///   if (guardcmp) goto preheader; else goto afterloop
  /// preheader:
  /// loop:
  ///   i1 = phi[{lb, preheader}, {i2, latch}]
  ///   <loop body>
  ///   i2 = i1 + step
  /// latch:
  ///   cmp = (i2 < ub)
  ///   if (cmp) goto loop
  /// exit:
  /// afterloop:
  ///
  /// getBounds
  ///   getInitialIVValue      --> lb
  ///   getStepInst            --> i2 = i1 + step
  ///   getStepValue           --> step
  ///   getFinalIVValue        --> ub
  ///   getCanonicalPredicate  --> '<'
  ///   getDirection           --> Increasing
  /// getGuard             --> if (guardcmp) goto loop; else goto afterloop
  /// getInductionVariable          --> i1
  /// getAuxiliaryInductionVariable --> {i1}
  /// isCanonical                   --> false


Repository:
  rL LLVM

https://reviews.llvm.org/D60565

Files:
  llvm/include/llvm/Analysis/LoopInfo.h
  llvm/include/llvm/Analysis/LoopInfoImpl.h
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/Transforms/Scalar/LoopInterchange.cpp
  llvm/unittests/Analysis/LoopInfoTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60565.194674.patch
Type: text/x-patch
Size: 45726 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190411/ab26b91c/attachment.bin>


More information about the llvm-commits mailing list