forked from OSchip/llvm-project
[Unroll] Refactor the accumulation of optimized instruction costs into
a single location. This reduces code duplication a bit and will also pave the way for a better separation between the visitation algorithm and the unroll analysis. No functionality changed. llvm-svn: 237990
This commit is contained in:
parent
1fca2edc48
commit
f174a156c3
|
@ -402,14 +402,10 @@ class UnrollAnalyzer : public InstVisitor<UnrollAnalyzer, bool> {
|
||||||
else
|
else
|
||||||
SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS, DL);
|
SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS, DL);
|
||||||
|
|
||||||
if (SimpleV)
|
if (Constant *C = dyn_cast_or_null<Constant>(SimpleV))
|
||||||
NumberOfOptimizedInstructions += TTI.getUserCost(&I);
|
|
||||||
|
|
||||||
if (Constant *C = dyn_cast_or_null<Constant>(SimpleV)) {
|
|
||||||
SimplifiedValues[&I] = C;
|
SimplifiedValues[&I] = C;
|
||||||
return true;
|
|
||||||
}
|
return SimpleV;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to fold load I.
|
/// Try to fold load I.
|
||||||
|
@ -452,7 +448,6 @@ class UnrollAnalyzer : public InstVisitor<UnrollAnalyzer, bool> {
|
||||||
assert(CV && "Constant expected.");
|
assert(CV && "Constant expected.");
|
||||||
SimplifiedValues[&I] = CV;
|
SimplifiedValues[&I] = CV;
|
||||||
|
|
||||||
NumberOfOptimizedInstructions += TTI.getUserCost(&I);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +566,13 @@ public:
|
||||||
// opportunities.
|
// opportunities.
|
||||||
for (Instruction &I : *BB) {
|
for (Instruction &I : *BB) {
|
||||||
UnrolledLoopSize += TTI.getUserCost(&I);
|
UnrolledLoopSize += TTI.getUserCost(&I);
|
||||||
Base::visit(I);
|
|
||||||
|
// Visit the instruction to analyze its loop cost after unrolling,
|
||||||
|
// and if the visitor returns true, then we can optimize this
|
||||||
|
// instruction away.
|
||||||
|
if (Base::visit(I))
|
||||||
|
NumberOfOptimizedInstructions += TTI.getUserCost(&I);
|
||||||
|
|
||||||
// If unrolled body turns out to be too big, bail out.
|
// If unrolled body turns out to be too big, bail out.
|
||||||
if (UnrolledLoopSize - NumberOfOptimizedInstructions >
|
if (UnrolledLoopSize - NumberOfOptimizedInstructions >
|
||||||
MaxUnrolledLoopSize)
|
MaxUnrolledLoopSize)
|
||||||
|
|
Loading…
Reference in New Issue