mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 05:31:51 +00:00
[Unroll] Add debug dumps to loop-unroll analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243471 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0ed54d8a2f
commit
c82121e77d
@ -543,11 +543,14 @@ analyzeLoopUnrollCost(const Loop *L, unsigned TripCount, ScalarEvolution &SE,
|
|||||||
// unrolling.
|
// unrolling.
|
||||||
unsigned RolledDynamicCost = 0;
|
unsigned RolledDynamicCost = 0;
|
||||||
|
|
||||||
|
DEBUG(dbgs() << "Starting LoopUnroll profitability analysis...\n");
|
||||||
|
|
||||||
// Simulate execution of each iteration of the loop counting instructions,
|
// Simulate execution of each iteration of the loop counting instructions,
|
||||||
// which would be simplified.
|
// which would be simplified.
|
||||||
// Since the same load will take different values on different iterations,
|
// Since the same load will take different values on different iterations,
|
||||||
// we literally have to go through all loop's iterations.
|
// we literally have to go through all loop's iterations.
|
||||||
for (unsigned Iteration = 0; Iteration < TripCount; ++Iteration) {
|
for (unsigned Iteration = 0; Iteration < TripCount; ++Iteration) {
|
||||||
|
DEBUG(dbgs() << " Analyzing iteration " << Iteration << "\n");
|
||||||
SimplifiedValues.clear();
|
SimplifiedValues.clear();
|
||||||
UnrolledInstAnalyzer Analyzer(Iteration, SimplifiedValues, L, SE);
|
UnrolledInstAnalyzer Analyzer(Iteration, SimplifiedValues, L, SE);
|
||||||
|
|
||||||
@ -568,14 +571,24 @@ analyzeLoopUnrollCost(const Loop *L, unsigned TripCount, ScalarEvolution &SE,
|
|||||||
// unrolled cost.
|
// unrolled cost.
|
||||||
if (!Analyzer.visit(I))
|
if (!Analyzer.visit(I))
|
||||||
UnrolledCost += InstCost;
|
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
|
// Also track this instructions expected cost when executing the rolled
|
||||||
// loop form.
|
// loop form.
|
||||||
RolledDynamicCost += InstCost;
|
RolledDynamicCost += InstCost;
|
||||||
|
|
||||||
// If unrolled body turns out to be too big, bail out.
|
// 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;
|
return None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorInst *TI = BB->getTerminator();
|
TerminatorInst *TI = BB->getTerminator();
|
||||||
@ -612,9 +625,15 @@ analyzeLoopUnrollCost(const Loop *L, unsigned TripCount, ScalarEvolution &SE,
|
|||||||
|
|
||||||
// If we found no optimization opportunities on the first iteration, we
|
// If we found no optimization opportunities on the first iteration, we
|
||||||
// won't find them on later ones too.
|
// 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;
|
return None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
DEBUG(dbgs() << "Analysis finished:\n"
|
||||||
|
<< "UnrolledCost: " << UnrolledCost << ", "
|
||||||
|
<< "RolledDynamicCost: " << RolledDynamicCost << "\n");
|
||||||
return {{UnrolledCost, RolledDynamicCost}};
|
return {{UnrolledCost, RolledDynamicCost}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user