[PATCH] D76132: [LoopUnrollAndJam] Changed safety checks to consider more than 2-levels loop nest.

Whitney Tsang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 13 07:28:40 PDT 2020


Whitney created this revision.
Whitney added reviewers: dmgreen, jdoerfert, Meinersbur, kbarton, bmahjour, etiotto.
Whitney added a project: LLVM.
Herald added subscribers: llvm-commits, zzheng, hiraditya.
Whitney marked 3 inline comments as done.
Whitney added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp:285
                       OptimizationRemarkEmitter &ORE, int OptLevel) {
-  // Quick checks of the correct loop form
-  if (!L->isLoopSimplifyForm() || L->getSubLoops().size() != 1)
----------------
Not needed as they are already checked in `isSafeToUnrollAndJam`


================
Comment at: llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp:441
 
-  // The loop unroll and jam pass requires loops to be in simplified form, and also needs LCSSA.
-  // Since simplification may add new inner loops, it has to run before the
----------------
Just clang-format


================
Comment at: llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp:758
 
-  if (!L->isLoopSimplifyForm() || L->getSubLoops().size() != 1)
-    return false;
----------------
Now done in `isEligibleLoopForm`


As discussed in https://reviews.llvm.org/D73129.

Example
Before unroll and jam:

  for
    A
    for
      B
      for
        C
      D
    E

After unroll and jam (currently):

  for
    A
    A'
    for
      B
      for
        C
      D
      B'
      for
        C'
      D'
    E
    E'

After unroll and jam (Ideal):

  for
    A
    A'
    for
      B
      B'
      for
        C
        C'
      D
      D
    E
    E

This is the first patch to change the safety checks needed to make sure is safe to unroll and jam in the ideal way.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76132

Files:
  llvm/include/llvm/Transforms/Utils/UnrollLoop.h
  llvm/lib/Transforms/Scalar/LoopUnrollAndJamPass.cpp
  llvm/lib/Transforms/Utils/LoopUnrollAndJam.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76132.250193.patch
Type: text/x-patch
Size: 16186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200313/1b0ac9b7/attachment.bin>


More information about the llvm-commits mailing list