[PATCH] D28073: Preserve domtree and loop-simplify for runtime unrolling.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 16:10:35 PST 2017


efriedma added inline comments.


================
Comment at: lib/Transforms/Utils/LoopUnroll.cpp:625-631
+        for (BasicBlock *IterLatch : Latches) {
+          TerminatorInst *Term = IterLatch->getTerminator();
+          if (isa<BranchInst>(Term) && cast<BranchInst>(Term)->isConditional()) {
+            NewIDom = IterLatch;
+            break;
+          }
+        }
----------------
mzolotukhin wrote:
> I think we should be able to tell which latch ends with a conditional. It should be either the first one (if all latches end with conditional branches), or the last one. Does it make sense? If so, can we remove this loop?
The actual conditional is complicated... if we're completely unrolling, it's either the first one or the last one, depending on PreserveCondBr.  If we're using a remainder loop, it's always the last one.  If we're partially unrolling without a remainder loop, it might not be the first or last one; there's a complicated conditional involving BreakingTrip and TripMultiple.  Anyway, this is much more straightforward than trying to duplicate the NeedConditional logic.


Repository:
  rL LLVM

https://reviews.llvm.org/D28073





More information about the llvm-commits mailing list