[PATCH] D51702: [LoopInterchange] Turn into a loop pass.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 5 12:11:21 PDT 2018


fhahn created this revision.
fhahn added reviewers: chandlerc, efriedma, mcrosier.
Herald added subscribers: kristof.beyls, mehdi_amini.
Herald added a reviewer: javed.absar.
fhahn added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopInterchange.cpp:434
+struct LoopInterchange : public LoopPass {
+  LPPassManager *LPM;
   static char ID;
----------------
Not needed, I'll drop it.


This patch turns LoopInterchange into a loop pass. It now only
considers top-level loops and tries to move the innermost loop to the
optimal position within the loop nest. By only looking at top-level
loops, we might miss a few opportunities the function pass would get
(e.g. if we have a loop nest of 3 loops, in the function pass
we might process loops at level 1 and 2 and move the inner most loop to
level 1, and then we process loops at levels 0, 1, 2 and interchange
again, because we now have a different inner loop). But I think it would
be better to handle such cases by picking the best inner loop from the
start and avoid re-visiting the same loops again.

The biggest advantage of it being a function pass is that it interacts
nicely with the other loop passes. Without this patch, there are some
performance regressions on AArch64 with loop interchanging enabled,
where no loops were interchanged, but we missed out on some other loop
optimizations.

It also removes the SimplifyCFG run. We are just changing branches, so
the CFG should not be more complicated, besides the additional 'unique'
preheaders this pass might create.


https://reviews.llvm.org/D51702

Files:
  lib/Transforms/IPO/PassManagerBuilder.cpp
  lib/Transforms/Scalar/LoopInterchange.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51702.164097.patch
Type: text/x-patch
Size: 6800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180905/7d06cf54/attachment.bin>


More information about the llvm-commits mailing list