Refactor the three main groups of code out of

NarrowSearchSpaceUsingHeuristics into separate functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112439 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-08-29 16:09:42 +00:00
parent e39a47c5b3
commit 4aa5c2e90f

View File

@ -1367,6 +1367,9 @@ public:
void FilterOutUndesirableDedicatedRegisters(); void FilterOutUndesirableDedicatedRegisters();
size_t EstimateSearchSpaceComplexity() const; size_t EstimateSearchSpaceComplexity() const;
void NarrowSearchSpaceByDetectingSupersets();
void NarrowSearchSpaceByCollapsingUnrolledCode();
void NarrowSearchSpaceByPickingWinnerRegs();
void NarrowSearchSpaceUsingHeuristics(); void NarrowSearchSpaceUsingHeuristics();
void SolveRecurse(SmallVectorImpl<const Formula *> &Solution, void SolveRecurse(SmallVectorImpl<const Formula *> &Solution,
@ -2905,11 +2908,11 @@ size_t LSRInstance::EstimateSearchSpaceComplexity() const {
return Power; return Power;
} }
/// NarrowSearchSpaceUsingHeuristics - If there are an extraordinary number of /// NarrowSearchSpaceByDetectingSupersets - When one formula uses a superset
/// formulae to choose from, use some rough heuristics to prune down the number /// of the registers of another formula, it won't help reduce register
/// of formulae. This keeps the main solver from taking an extraordinary amount /// pressure (though it may not necessarily hurt register pressure); remove
/// of time in some worst-case scenarios. /// it to simplify the system.
void LSRInstance::NarrowSearchSpaceUsingHeuristics() { void LSRInstance::NarrowSearchSpaceByDetectingSupersets() {
if (EstimateSearchSpaceComplexity() >= ComplexityLimit) { if (EstimateSearchSpaceComplexity() >= ComplexityLimit) {
DEBUG(dbgs() << "The search space is too complex.\n"); DEBUG(dbgs() << "The search space is too complex.\n");
@ -2967,7 +2970,12 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
DEBUG(dbgs() << "After pre-selection:\n"; DEBUG(dbgs() << "After pre-selection:\n";
print_uses(dbgs())); print_uses(dbgs()));
} }
}
/// NarrowSearchSpaceByCollapsingUnrolledCode - When there are many registers
/// for expressions like A, A+1, A+2, etc., allocate a single register for
/// them.
void LSRInstance::NarrowSearchSpaceByCollapsingUnrolledCode() {
if (EstimateSearchSpaceComplexity() >= ComplexityLimit) { if (EstimateSearchSpaceComplexity() >= ComplexityLimit) {
DEBUG(dbgs() << "The search space is too complex.\n"); DEBUG(dbgs() << "The search space is too complex.\n");
@ -3038,7 +3046,12 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
DEBUG(dbgs() << "After pre-selection:\n"; DEBUG(dbgs() << "After pre-selection:\n";
print_uses(dbgs())); print_uses(dbgs()));
} }
}
/// NarrowSearchSpaceByPickingWinnerRegs - Pick a register which seems likely
/// to be profitable, and then in any use which has any reference to that
/// register, delete all formulae which do not reference that register.
void LSRInstance::NarrowSearchSpaceByPickingWinnerRegs() {
// With all other options exhausted, loop until the system is simple // With all other options exhausted, loop until the system is simple
// enough to handle. // enough to handle.
SmallPtrSet<const SCEV *, 4> Taken; SmallPtrSet<const SCEV *, 4> Taken;
@ -3100,6 +3113,16 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
} }
} }
/// NarrowSearchSpaceUsingHeuristics - If there are an extraordinary number of
/// formulae to choose from, use some rough heuristics to prune down the number
/// of formulae. This keeps the main solver from taking an extraordinary amount
/// of time in some worst-case scenarios.
void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
NarrowSearchSpaceByDetectingSupersets();
NarrowSearchSpaceByCollapsingUnrolledCode();
NarrowSearchSpaceByPickingWinnerRegs();
}
/// SolveRecurse - This is the recursive solver. /// SolveRecurse - This is the recursive solver.
void LSRInstance::SolveRecurse(SmallVectorImpl<const Formula *> &Solution, void LSRInstance::SolveRecurse(SmallVectorImpl<const Formula *> &Solution,
Cost &SolutionCost, Cost &SolutionCost,