summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/pragma-unroll.cpp
diff options
context:
space:
mode:
authorTyler Nowicki <tyler.nowicki@gmail.com>2015-07-27 20:10:20 +0000
committerTyler Nowicki <tyler.nowicki@gmail.com>2015-07-27 20:10:20 +0000
commit54c020d372defdef97235f4849e07292eb2f03ad (patch)
treebe6872130c8b6e2c8a03ec871727b58bebef59a6 /clang/test/CodeGenCXX/pragma-unroll.cpp
parent917c4d41eafcd9da0cdc1ac0379d654560578e04 (diff)
downloadbcm5719-llvm-54c020d372defdef97235f4849e07292eb2f03ad.tar.gz
bcm5719-llvm-54c020d372defdef97235f4849e07292eb2f03ad.zip
Use CGLoopInfo to emit metadata for loop hint pragmas.
When ‘#pragma clang loop vectorize(assume_safety)’ was specified on a loop other loop hints were lost. The problem is that CGLoopInfo attaches metadata differently than EmitCondBrHints in CGStmt. For do-loops CGLoopInfo attaches metadata to the br in the body block and for while and for loops, the inc block. EmitCondBrHints on the other hand always attaches data to the br in the cond block. When specifying assume_safety CGLoopInfo emits an empty llvm.loop metadata shadowing the metadata in the cond block. Loop transformations like rotate and unswitch would then eliminate the cond block and its non-empty metadata. This patch unifies both approaches for adding metadata and modifies the existing safety tests to include non-assume_safety loop hints. llvm-svn: 243315
Diffstat (limited to 'clang/test/CodeGenCXX/pragma-unroll.cpp')
-rw-r--r--clang/test/CodeGenCXX/pragma-unroll.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/test/CodeGenCXX/pragma-unroll.cpp b/clang/test/CodeGenCXX/pragma-unroll.cpp
index 8b73fa6c8aa..0b13bde0fa0 100644
--- a/clang/test/CodeGenCXX/pragma-unroll.cpp
+++ b/clang/test/CodeGenCXX/pragma-unroll.cpp
@@ -7,7 +7,7 @@ void while_test(int *List, int Length) {
#pragma unroll
while (i < Length) {
- // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
+ // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
List[i] = i * 2;
i++;
}
@@ -15,6 +15,7 @@ void while_test(int *List, int Length) {
// Verify do loop is recognized after multi-option pragma clang loop directive.
void do_test(int *List, int Length) {
+ // CHECK: define {{.*}} @_Z7do_test
int i = 0;
#pragma nounroll
@@ -27,20 +28,22 @@ void do_test(int *List, int Length) {
// Verify for loop is recognized after unroll pragma.
void for_test(int *List, int Length) {
+// CHECK: define {{.*}} @_Z8for_test
#pragma unroll 8
for (int i = 0; i < Length; i++) {
- // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_3:.*]]
+ // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_3:.*]]
List[i] = i * 2;
}
}
// Verify c++11 for range loop is recognized after unroll pragma.
void for_range_test() {
+ // CHECK: define {{.*}} @_Z14for_range_test
double List[100];
#pragma unroll(4)
for (int i : List) {
- // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_4:.*]]
+ // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_4:.*]]
List[i] = i;
}
}
@@ -49,9 +52,10 @@ void for_range_test() {
// Verify defines are correctly resolved in unroll pragmas.
void for_define_test(int *List, int Length, int Value) {
+// CHECK: define {{.*}} @_Z15for_define_test
#pragma unroll(UNROLLCOUNT)
for (int i = 0; i < Length; i++) {
- // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_5:.*]]
+ // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_5:.*]]
List[i] = i * Value;
}
}
@@ -59,9 +63,10 @@ void for_define_test(int *List, int Length, int Value) {
// Verify metadata is generated when template is used.
template <typename A>
void for_template_test(A *List, int Length, A Value) {
+// CHECK: define {{.*}} @_Z13template_test
#pragma unroll 8
for (int i = 0; i < Length; i++) {
- // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_6:.*]]
+ // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_6:.*]]
List[i] = i * Value;
}
}
@@ -69,9 +74,11 @@ void for_template_test(A *List, int Length, A Value) {
// Verify define is resolved correctly when template is used.
template <typename A>
void for_template_define_test(A *List, int Length, A Value) {
+// CHECK: define {{.*}} @_Z24for_template_define_test
+
#pragma unroll(UNROLLCOUNT)
for (int i = 0; i < Length; i++) {
- // CHECK: br i1 {{.*}}, label {{.*}}, label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
+ // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_7:.*]]
List[i] = i * Value;
}
}
OpenPOWER on IntegriCloud