[PATCH] D30632: [LoopUnrolling] Fix loop size check for peeling

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 02:23:25 PST 2017


mkazantsev added inline comments.


================
Comment at: lib/Transforms/Utils/LoopUnrollPeel.cpp:78
   // invariant instead of this Phi.
-  if (auto *BackEdge = L->getLoopLatch()) {
-    BasicBlock *Header = L->getHeader();
-    // Iterate over Phis to find one with invariant input on back edge.
-    bool FoundCandidate = false;
-    PHINode *Phi;
-    for (auto BI = Header->begin(); isa<PHINode>(&*BI); ++BI) {
-      Phi = cast<PHINode>(&*BI);
-      Value *Input = Phi->getIncomingValueForBlock(BackEdge);
-      if (L->isLoopInvariant(Input)) {
-        FoundCandidate = true;
-        break;
+  if (LoopSize <= UP.Threshold) {
+    if (auto *BackEdge = L->getLoopLatch()) {
----------------
mkuper wrote:
> I would combine this into a single if with a &&, rather than two nested ones.
We can't combine it with variable's declaration, and declaring the latch externally looks quite ugly.


https://reviews.llvm.org/D30632





More information about the llvm-commits mailing list