[llvm-dev] [GSoC 2021] Utilize LoopNest Pass

Whitney T Tsang via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 15 06:16:58 PDT 2021


Passes implemented as a loop pass can still be good for this change.
I am referring to passes implemented as a loop pass and used as a loop pass
in a loop pipeline may not be a good candidate.
Take the LoopFullUnrollPass as an example, LoopFullUnrollPass is added in
LPM2 with other loop passes, e.g. LoopIdiomRecognizePass,
IndVarSimplifyPass, ...
Loops are processed from inner to outer loop, where each loop is processed
by all the passes in LPM2, before process its outer loops.
If we change LoopFullUnrollPass to a LoopNest pass, then there is no way we
can preserve the same order of processing loops.
It may still be good to change such passes, but there can be huge
performance impact, which we need to analyze and handle, and probably not
the best choice to look at first.

```
LoopPassManager LPM2(DebugLogging);

LPM2.addPass(LoopIdiomRecognizePass());
LPM2.addPass(IndVarSimplifyPass());

for (auto &C : LateLoopOptimizationsEPCallbacks)
  C(LPM2, Level);

LPM2.addPass(LoopDeletionPass());

if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink || !PGOOpt ||
     PGOOpt->Action != PGOOptions::SampleUse)
  LPM2.addPass(LoopFullUnrollPass(Level.getSpeedupLevel(),
     /* OnlyWhenForced= */ !PTO.LoopUnrolling,
     PTO.ForgetAllSCEVInLoopUnroll));

for (auto &C : LoopOptimizerEndEPCallbacks)
  (LPM2, Level);

FPM.addPass(createFunctionToLoopPassAdaptor(
    std::move(LPM2), /*UseMemorySSA=*/false, /*UseBlockFrequencyInfo=*/
false,
    DebugLogging));
```

Regards,
Whitney Tsang



From:	uint256_t <konndennsa at gmail.com>
To:	Whitney T Tsang <whitneyt at ca.ibm.com>
Cc:	etiotto at ca.ibm.com, llvm-dev <llvm-dev at lists.llvm.org>
Date:	2021/03/14 08:48 PM
Subject:	[EXTERNAL] Re: [llvm-dev] [GSoC 2021] Utilize LoopNest Pass



Hello,

I have a question about finding good passes for utilizing LoopNest pass.

> The LoopFullUnrollPass is not a good candidate for the change, as it is a
loop pass and it is being used as a loop pass.
Then you mean that passes which are  implemented as not a loop pass (=
function pass) and not already used as a loop pass are good for this
change?
I didn't get that. Could you tell me why it is?

Thanks in advance,
Toshiki Maekawa

On Fri, Mar 12, 2021, 1:20 AM uint256_t <konndennsa at gmail.com> wrote:
  Thank you for your advice. As you mentioned, LoopUnrollAndJam seems to be
  a good candidate.
  I'm going to find another analyse/transform pass suitable for loop nest
  pass.

  Best,
  Toshiki Maekawa

  2021年3月10日(水) 23:32 Whitney T Tsang <whitneyt at ca.ibm.com>:
   Sure, in this project, we plan to utilize the LoopNest pass in some
   existing passes.
   As an example, here is one of the patches to transform the loop
   interchange pass: https://reviews.llvm.org/D97847.
   On top of doing the code changes, we want to understand what are the
   pros and cons of the change.
   We can do that by collecting some data, e.g. compile time.

   There are two loop unroller, LoopFullUnrollPass and LoopUnrollPass.
   The LoopFullUnrollPass is not a good candidate for the change, as it is
   a loop pass and it is being used as a loop pass.
   It is written to be traverse from inner to outer loop, with other loop
   transformations in between in the loop pipeline.
   The LoopUnrollPass could be a candidate, but the LoopUnrollAndJamPass
   can be an easier to understand candidate,
   as unroll and jam transformation naturally operate on more than one loop
   (LoopNest).

   Regards,
   Whitney Tsang

   Inactive hide details for uint256_t ---2021/03/10 07:52:17 AM---I'm glad
   to get in touch with you two. I'm planning to utilizeuint256_t
   ---2021/03/10 07:52:17 AM---I'm glad to get in touch with you two. I'm
   planning to utilize LoopNest pass for some passes like lo

   From: uint256_t <konndennsa at gmail.com>
   To:
   Cc: llvm-dev <llvm-dev at lists.llvm.org>, etiotto at ca.ibm.com,
   whitneyt at ca.ibm.com
   Date: 2021/03/10 07:52 AM
   Subject: [EXTERNAL] Re: [llvm-dev] [GSoC 2021] Utilize LoopNest Pass


   ZjQcmQRYFpfptBannerEnd
   I'm glad to get in touch with you two.
   I'm planning to utilize LoopNest pass for some passes like loop
   unrolling.
   Could you tell me more about this project if any?

   2021年3月9日(火) 20:47 Whitney Tsang <whitney.uwaterloo at gmail.com>:
         + Whitney, Ettore

         On Tue, Mar 9, 2021, 3:00 AM uint256_t via llvm-dev <
         llvm-dev at lists.llvm.org> wrote:
         Hello,

         I'm thinking of participating in GSoC at LLVM.
         I've already talked about ideas with some project mentors but a
         newly added project idea "Utilize LoopNest Pass" attracted me.
         I want to get in touch with its mentors (Whitney Tsang, Ettore
         Tiotto), whose email I couldn't find out.

         Sincerely,
         Toshiki Maekawa
         _______________________________________________
         LLVM Developers mailing list
         llvm-dev at lists.llvm.org
         https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210315/06d7f13d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210315/06d7f13d/attachment-0001.gif>


More information about the llvm-dev mailing list