summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2019-10-14 22:56:07 +0000
committerEric Christopher <echristo@gmail.com>2019-10-14 22:56:07 +0000
commit0776661d41fa312e1457b8e7cde971ab685a07f2 (patch)
treea2c257baaa2a60e26764efb9b2f89570c8aa9726
parentcf93188cfc0a51183cf9e15673a6b9c8bbd020c2 (diff)
downloadclang-0776661d41fa312e1457b8e7cde971ab685a07f2.tar.gz
In the new pass manager use PTO.LoopUnrolling to determine when and how
we will unroll loops. Also comment a few occasions where we need to know whether or not we're forcing the unwinder or not. The default before and after this patch is for LoopUnroll to be enabled, and for it to use a cost model to determine whether to unroll the loop (`OnlyWhenForced = false`). Before this patch, disabling loop unroll would not run the LoopUnroll pass. After this patch, the LoopUnroll pass is being run, but it restricts unrolling to only the loops marked by a pragma (`OnlyWhenForced = true`). In addition, this patch disables the UnrollAndJam pass when disabling unrolling. Testcase is in clang because it's controlling how the loop optimizer is being set up and there's no other way to trigger the behavior. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374838 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Misc/loop-opt-setup.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/Misc/loop-opt-setup.c b/test/Misc/loop-opt-setup.c
new file mode 100644
index 0000000000..8d3835b448
--- /dev/null
+++ b/test/Misc/loop-opt-setup.c
@@ -0,0 +1,12 @@
+// RUN: %clang -O1 -fexperimental-new-pass-manager -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
+// RUN: %clang -O1 -fno-unroll-loops -S -o - %s -emit-llvm | FileCheck %s
+extern int a[16];
+int b = 0;
+int foo(void) {
+#pragma unroll
+ for (int i = 0; i < 16; ++i)
+ a[i] = b += 2;
+ return b;
+}
+// CHECK-NOT: br i1
+