[PATCH] D80477: [LoopUnroll] Support loops with exiting block that is neither header nor latch.

Whitney Tsang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 26 19:05:46 PDT 2020


Whitney added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopUnroll.cpp:315
 
-  // FIXME: Support loops without conditional latch and multiple exiting blocks.
-  if (!BI ||
-      (BI->isUnconditional() && (!HeaderBI || HeaderBI->isUnconditional() ||
-                                 L->getExitingBlock() != Header))) {
+  BranchInst *BI = nullptr;
+  if (L->isLoopExiting(LatchBlock))
----------------
efriedma wrote:
> Maybe call this ExitingBI?  And put a comment something like the following:
> 
> ```
> // A conditional branch which exits the loop, which can be optimized to an
> // unconditional branch in the unrolled loop in some cases.
> ```
> 
> -----
> 
> We could probably allow unrolling even if ExitingBI is null, but we can leave that as a followup.
> We could probably allow unrolling even if ExitingBI is null, but we can leave that as a followup.

That's one of the things I wanted to do in the original patch, but I probably described it very confusingly, by optimizing one exiting block instead of null.
I will do that after this patch landed with more test cases. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80477/new/

https://reviews.llvm.org/D80477





More information about the llvm-commits mailing list