summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2016-01-11 22:39:43 +0000
committerJustin Bogner <mail@justinbogner.com>2016-01-11 22:39:43 +0000
commit0fb7ed5726f1470f6e117f72ed629fad74862187 (patch)
tree589854d4d8f41c302cde3923ba0521d4c9a38c63
parent9f67dadea2fd6b16dfc9a3bf9ef2aed6064e051c (diff)
downloadbcm5719-llvm-0fb7ed5726f1470f6e117f72ed629fad74862187.tar.gz
bcm5719-llvm-0fb7ed5726f1470f6e117f72ed629fad74862187.zip
LoopUnroll: Use the optsize threshold for minsize as well
Currently we're unrolling loops more in minsize than in optsize, which means -Oz will have a larger code size than -Os. That doesn't make any sense. This resolves the FIXME about this in LoopUnrollPass and extends the optsize test to make sure we use the smaller threshold for minsize as well. llvm-svn: 257402
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp5
-rw-r--r--llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll3
2 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
index 56ae5c01041..bc0f1e9f400 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -209,10 +209,7 @@ namespace {
? CurrentDynamicCostSavingsDiscount
: UP.DynamicCostSavingsDiscount;
- if (!UserThreshold &&
- // FIXME: Use Function::optForSize().
- L->getHeader()->getParent()->hasFnAttribute(
- Attribute::OptimizeForSize)) {
+ if (!UserThreshold && L->getHeader()->getParent()->optForSize()) {
Threshold = UP.OptSizeThreshold;
PartialThreshold = UP.PartialOptSizeThreshold;
}
diff --git a/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll b/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll
index a650317f3df..e5e0151761b 100644
--- a/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll
+++ b/llvm/test/Transforms/LoopUnroll/partial-unroll-optsize.ll
@@ -1,4 +1,6 @@
; RUN: opt < %s -S -loop-unroll -unroll-allow-partial | FileCheck %s
+; RUN: sed -e 's/optsize/minsize/' %s | opt -S -loop-unroll -unroll-allow-partial | FileCheck %s
+
; Loop size = 3, when the function has the optsize attribute, the
; OptSizeUnrollThreshold, i.e. 50, is used, hence the loop should be unrolled
; by 32 times because (1 * 32) + 2 < 50 (whereas (1 * 64 + 2) is not).
@@ -49,4 +51,3 @@ exit:
; CHECK-NEXT: add
; CHECK-NEXT: add
; CHECK-NEXT: icmp
-
OpenPOWER on IntegriCloud