diff options
author | Anna Thomas <anna@azul.com> | 2017-07-11 20:44:37 +0000 |
---|---|---|
committer | Anna Thomas <anna@azul.com> | 2017-07-11 20:44:37 +0000 |
commit | bafe766f5d85486c8bc0c49a1316fe45a25acc0b (patch) | |
tree | f7823f041b8d24045a44727b5585877aaf27e099 /llvm/lib | |
parent | e12d036d13b3c86c05639ac7696ebee2fd90344b (diff) | |
download | bcm5719-llvm-bafe766f5d85486c8bc0c49a1316fe45a25acc0b.tar.gz bcm5719-llvm-bafe766f5d85486c8bc0c49a1316fe45a25acc0b.zip |
[LoopUnrollRuntime] NFC: Add some debugging trace messages for why loop wasn't unrolled.
llvm-svn: 307705
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp index 2b432426b24..9fbc00fbb01 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -471,21 +471,31 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count, LoopInfo *LI, ScalarEvolution *SE, DominatorTree *DT, bool PreserveLCSSA) { bool hasMultipleExitingBlocks = !L->getExitingBlock(); + DEBUG(dbgs() << "Trying runtime unrolling on Loop: \n"); + DEBUG(L->dump()); // Support only single exiting block unless UnrollRuntimeMultiExit is true. - if (!UnrollRuntimeMultiExit && hasMultipleExitingBlocks) + if (!UnrollRuntimeMultiExit && hasMultipleExitingBlocks) { + DEBUG( + dbgs() + << "Multiple exiting blocks and UnrollRuntimeMultiExit not enabled!\n"); return false; + } // Make sure the loop is in canonical form. - if (!L->isLoopSimplifyForm()) + if (!L->isLoopSimplifyForm()) { + DEBUG(dbgs() << "Not in simplify form!\n"); return false; + } // Guaranteed by LoopSimplifyForm. BasicBlock *Latch = L->getLoopLatch(); BasicBlock *Header = L->getHeader(); BasicBlock *LatchExit = L->getUniqueExitBlock(); // successor out of loop - if (!LatchExit && !UnrollRuntimeMultiExit) + if (!LatchExit && !UnrollRuntimeMultiExit) { + DEBUG(dbgs() << "No unique exit block and UnrollRuntimeMultiExit not enabled\n"); return false; + } // These are exit blocks other than the target of the latch exiting block. SmallVector<BasicBlock *, 4> OtherExits; BranchInst *LatchBR = cast<BranchInst>(Latch->getTerminator()); @@ -515,8 +525,11 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count, // TODO: Support multiple exiting blocks jumping to the `LatchExit` when // UnrollRuntimeMultiExit is true. This will need updating the logic in // connectEpilog. - if (!LatchExit->getSinglePredecessor()) + if (!LatchExit->getSinglePredecessor()) { + DEBUG(dbgs() << "Bailout for multi-exit handling when latch exit has >1 " + "predecessor.\n"); return false; + } // FIXME: We bail out of multi-exit unrolling when epilog loop is generated // and L is an inner loop. This is because in presence of multiple exits, the // outer loop is incorrect: we do not add the EpilogPreheader and exit to the @@ -537,29 +550,38 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count, // exiting blocks). const SCEV *BECountSC = SE->getExitCount(L, Latch); if (isa<SCEVCouldNotCompute>(BECountSC) || - !BECountSC->getType()->isIntegerTy()) + !BECountSC->getType()->isIntegerTy()) { + DEBUG(dbgs() << "Could not compute exit block SCEV\n"); return false; + } unsigned BEWidth = cast<IntegerType>(BECountSC->getType())->getBitWidth(); // Add 1 since the backedge count doesn't include the first loop iteration. const SCEV *TripCountSC = SE->getAddExpr(BECountSC, SE->getConstant(BECountSC->getType(), 1)); - if (isa<SCEVCouldNotCompute>(TripCountSC)) + if (isa<SCEVCouldNotCompute>(TripCountSC)) { + DEBUG(dbgs() << "Could not compute trip count SCEV.\n"); return false; + } BasicBlock *PreHeader = L->getLoopPreheader(); BranchInst *PreHeaderBR = cast<BranchInst>(PreHeader->getTerminator()); const DataLayout &DL = Header->getModule()->getDataLayout(); SCEVExpander Expander(*SE, DL, "loop-unroll"); if (!AllowExpensiveTripCount && - Expander.isHighCostExpansion(TripCountSC, L, PreHeaderBR)) + Expander.isHighCostExpansion(TripCountSC, L, PreHeaderBR)) { + DEBUG(dbgs() << "High cost for expanding trip count scev!\n"); return false; + } // This constraint lets us deal with an overflowing trip count easily; see the // comment on ModVal below. - if (Log2_32(Count) > BEWidth) + if (Log2_32(Count) > BEWidth) { + DEBUG(dbgs() + << "Count failed constraint on overflow trip count calculation.\n"); return false; + } // Loop structure is the following: // |