summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-05-22 02:47:29 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-05-22 02:47:29 +0000
commitf174a156c365429e6acd8e025ba6875a9e4b7e58 (patch)
tree2377517edc080ed6d0f98a9f5a3b7bca51c448e9 /llvm/lib/Transforms
parent1fca2edc488e73b2c022ac274bc276e654fe7432 (diff)
downloadbcm5719-llvm-f174a156c365429e6acd8e025ba6875a9e4b7e58.tar.gz
bcm5719-llvm-f174a156c365429e6acd8e025ba6875a9e4b7e58.zip
[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
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 03e1f4cbf60..9f142a6b357 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -402,14 +402,10 @@ class UnrollAnalyzer : public InstVisitor<UnrollAnalyzer, bool> {
else
SimpleV = SimplifyBinOp(I.getOpcode(), LHS, RHS, DL);
- if (SimpleV)
- NumberOfOptimizedInstructions += TTI.getUserCost(&I);
-
- if (Constant *C = dyn_cast_or_null<Constant>(SimpleV)) {
+ if (Constant *C = dyn_cast_or_null<Constant>(SimpleV))
SimplifiedValues[&I] = C;
- return true;
- }
- return false;
+
+ return SimpleV;
}
/// Try to fold load I.
@@ -452,7 +448,6 @@ class UnrollAnalyzer : public InstVisitor<UnrollAnalyzer, bool> {
assert(CV && "Constant expected.");
SimplifiedValues[&I] = CV;
- NumberOfOptimizedInstructions += TTI.getUserCost(&I);
return true;
}
@@ -571,7 +566,13 @@ public:
// opportunities.
for (Instruction &I : *BB) {
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 (UnrolledLoopSize - NumberOfOptimizedInstructions >
MaxUnrolledLoopSize)
OpenPOWER on IntegriCloud