summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Zolotukhin <mzolotukhin@apple.com>2016-08-23 23:13:15 +0000
committerMichael Zolotukhin <mzolotukhin@apple.com>2016-08-23 23:13:15 +0000
commitbd63d436c148152aedf13818475e66892449662b (patch)
tree9974b420d33efd12676b6700667e44abf1f0c6a7
parent12a0b1f4c847a3dd8efc53b2fe1746fea7f2edc5 (diff)
downloadbcm5719-llvm-bd63d436c148152aedf13818475e66892449662b.tar.gz
bcm5719-llvm-bd63d436c148152aedf13818475e66892449662b.zip
[LoopUnroll] By default disable unrolling when optimizing for size.
Summary: In clang commit r268509 we started to invoke loop-unroll pass from the driver even under -Os. However, we happen to not initialize optsize thresholds properly, which si fixed with this change. r268509 led to some big compile time regressions, because we started to unroll some loops that we didn't unroll before. With this change I hope to recover most of the regressions. We still are slightly slower than before, because we do some checks here and there in loop-unrolling before we bail out, but at least the slowdown is not that huge now. Reviewers: hfinkel, chandlerc Subscribers: mzolotukhin, llvm-commits Differential Revision: https://reviews.llvm.org/D23388 llvm-svn: 279585
-rw-r--r--llvm/include/llvm/CodeGen/BasicTTIImpl.h6
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp4
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index c4480ffdb9e..b1a29d56464 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -285,7 +285,11 @@ public:
// Enable runtime and partial unrolling up to the specified size.
UP.Partial = UP.Runtime = true;
- UP.PartialThreshold = UP.PartialOptSizeThreshold = MaxOps;
+ UP.PartialThreshold = MaxOps;
+
+ // Avoid unrolling when optimizing for size.
+ UP.OptSizeThreshold = 0;
+ UP.PartialOptSizeThreshold = 0;
}
/// @}
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index f53ac86b14c..1018b61b330 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -948,6 +948,10 @@ static bool tryToUnrollLoop(Loop *L, DominatorTree &DT, LoopInfo *LI,
L, TTI, ProvidedThreshold, ProvidedCount, ProvidedAllowPartial,
ProvidedRuntime);
+ // Exit early if unrolling is disabled.
+ if (UP.Threshold == 0 && (!UP.Partial || UP.PartialThreshold == 0))
+ return false;
+
// If the loop contains a convergent operation, the prelude we'd add
// to do the first few instructions before we hit the unrolled loop
// is unsafe -- it adds a control-flow dependency to the convergent
OpenPOWER on IntegriCloud