[llvm] r243471 - [Unroll] Add debug dumps to loop-unroll analyzer.
Michael Zolotukhin
mzolotukhin at apple.com
Tue Jul 28 13:07:29 PDT 2015
Author: mzolotukhin
Date: Tue Jul 28 15:07:29 2015
New Revision: 243471
URL: http://llvm.org/viewvc/llvm-project?rev=243471&view=rev
Log:
[Unroll] Add debug dumps to loop-unroll analyzer.
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp?rev=243471&r1=243470&r2=243471&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnrollPass.cpp Tue Jul 28 15:07:29 2015
@@ -543,11 +543,14 @@ analyzeLoopUnrollCost(const Loop *L, uns
// unrolling.
unsigned RolledDynamicCost = 0;
+ DEBUG(dbgs() << "Starting LoopUnroll profitability analysis...\n");
+
// Simulate execution of each iteration of the loop counting instructions,
// which would be simplified.
// Since the same load will take different values on different iterations,
// we literally have to go through all loop's iterations.
for (unsigned Iteration = 0; Iteration < TripCount; ++Iteration) {
+ DEBUG(dbgs() << " Analyzing iteration " << Iteration << "\n");
SimplifiedValues.clear();
UnrolledInstAnalyzer Analyzer(Iteration, SimplifiedValues, L, SE);
@@ -568,14 +571,24 @@ analyzeLoopUnrollCost(const Loop *L, uns
// unrolled cost.
if (!Analyzer.visit(I))
UnrolledCost += InstCost;
+ else {
+ DEBUG(dbgs() << " " << I
+ << " would be simplified if loop is unrolled.\n");
+ (void)0;
+ }
// Also track this instructions expected cost when executing the rolled
// loop form.
RolledDynamicCost += InstCost;
// If unrolled body turns out to be too big, bail out.
- if (UnrolledCost > MaxUnrolledLoopSize)
+ if (UnrolledCost > MaxUnrolledLoopSize) {
+ DEBUG(dbgs() << " Exceeded threshold.. exiting.\n"
+ << " UnrolledCost: " << UnrolledCost
+ << ", MaxUnrolledLoopSize: " << MaxUnrolledLoopSize
+ << "\n");
return None;
+ }
}
TerminatorInst *TI = BB->getTerminator();
@@ -612,9 +625,15 @@ analyzeLoopUnrollCost(const Loop *L, uns
// If we found no optimization opportunities on the first iteration, we
// won't find them on later ones too.
- if (UnrolledCost == RolledDynamicCost)
+ if (UnrolledCost == RolledDynamicCost) {
+ DEBUG(dbgs() << " No opportunities found.. exiting.\n"
+ << " UnrolledCost: " << UnrolledCost << "\n");
return None;
+ }
}
+ DEBUG(dbgs() << "Analysis finished:\n"
+ << "UnrolledCost: " << UnrolledCost << ", "
+ << "RolledDynamicCost: " << RolledDynamicCost << "\n");
return {{UnrolledCost, RolledDynamicCost}};
}
More information about the llvm-commits
mailing list