summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-05-24 17:40:52 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-05-24 17:40:52 +0000
commit21efe2afed7b743f37780f39b090af6145b4d527 (patch)
treeb132b2aeeb057bb2807bc6c97203c7a1bd342373 /clang
parent4105882b87e5070d5918bec7b80157b9749180f8 (diff)
downloadbcm5719-llvm-21efe2afed7b743f37780f39b090af6145b4d527.tar.gz
bcm5719-llvm-21efe2afed7b743f37780f39b090af6145b4d527.zip
[NewPassManager] Add tuning option: LoopUnrolling [clang-change]
Summary: Use CodeGenOpts's setting for loop unrolling. [to be coupled with D61618] Reviewers: chandlerc Subscribers: jlebar, dmgreen, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61620 llvm-svn: 361653
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp1
-rw-r--r--clang/test/CodeGen/loop-unroll.c55
2 files changed, 56 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 1dbeec1c178..c5e56c7a069 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1051,6 +1051,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
}
PipelineTuningOptions PTO;
+ PTO.LoopUnrolling = CodeGenOpts.UnrollLoops;
// For historical reasons, loop interleaving is set to mirror setting for loop
// unrolling.
PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
diff --git a/clang/test/CodeGen/loop-unroll.c b/clang/test/CodeGen/loop-unroll.c
new file mode 100644
index 00000000000..c37411fa052
--- /dev/null
+++ b/clang/test/CodeGen/loop-unroll.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -funroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-ENABLE-UNROLL
+// RUN: %clang_cc1 -triple x86_64 -target-cpu x86-64 -fexperimental-new-pass-manager -S -O1 -fno-unroll-loops -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-DISABLE-UNROLL
+
+// CHECK-ENABLE-UNROLL-LABEL: @for_test()
+// CHECK-ENABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-ENABLE-UNROLL: [[FORBODY]]:
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-ENABLE-UNROLL: [[FORBODY5]]:
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+// CHECK-ENABLE-UNROLL: fmul
+// CHECK-ENABLE-UNROLL: fadd
+// CHECK-ENABLE-UNROLL: store
+
+// CHECK-DISABLE-UNROLL-LABEL: @for_test()
+// CHECK-DISABLE-UNROLL: br label %[[FORBODY:[a-z0-9_\.]+]]
+// CHECK-DISABLE-UNROLL: [[FORBODY]]:
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: store
+// CHECK-DISABLE-UNROLL: br i1 %[[EXITCOND:[a-z0-9_\.]+]], label %[[FORBODY5:[a-z0-9_\.]+]], label %[[FORBODY]]
+// CHECK-DISABLE-UNROLL: [[FORBODY5]]:
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL: fmul
+// CHECK-DISABLE-UNROLL: fadd
+// CHECK-DISABLE-UNROLL: store
+// CHECK-DISABLE-UNROLL-NOT: fmul
+// CHECK-DISABLE-UNROLL-NOT: fadd
+// CHECK-DISABLE-UNROLL-NOT: store
+
+int printf(const char * restrict format, ...);
+
+void for_test() {
+ double A[1000], B[1000];
+ int L = 500;
+ for (int i = 0; i < L; i++) {
+ A[i] = i;
+ }
+ for (int i = 0; i < L; i++) {
+ B[i] = A[i]*5;
+ B[i]++;
+ A[i] *= 7;
+ A[i]++;
+ }
+ printf("%lf %lf\n", A[0], B[0]);
+}
OpenPOWER on IntegriCloud