Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / loop_bind_codegen.cpp
blob8ce12fb07402ab5afb0754e50f9be3ac5c6704ca
1 // expected-no-diagnostics
2 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ %s -emit-llvm -o - | FileCheck %s
3 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
6 #define NNN 50
7 int aaa[NNN];
9 void parallel_loop() {
10 #pragma omp parallel
12 #pragma omp loop bind(parallel)
13 for (int j = 0 ; j < NNN ; j++) {
14 aaa[j] = j*NNN;
19 void parallel_loop_orphan() {
20 #pragma omp loop bind(parallel)
21 for (int j = 0 ; j < NNN ; j++) {
22 aaa[j] = j*NNN;
27 void teams_loop() {
28 #pragma omp teams
30 #pragma omp loop bind(teams)
31 for (int j = 0 ; j < NNN ; j++) {
32 aaa[j] = j*NNN;
37 void thread_loop() {
38 #pragma omp parallel
40 #pragma omp loop bind(thread)
41 for (int j = 0 ; j < NNN ; j++) {
42 aaa[j] = j*NNN;
47 void thread_loop_orphan() {
48 #pragma omp loop bind(thread)
49 for (int j = 0 ; j < NNN ; j++) {
50 aaa[j] = j*NNN;
54 int main() {
55 parallel_loop();
56 parallel_loop_orphan();
57 teams_loop();
58 thread_loop();
59 thread_loop_orphan();
61 return 0;
63 // CHECK-LABEL: define {{.+}}parallel_loop{{.+}}
64 // CHECK: call {{.+}}__kmpc_fork_call({{.+}}parallel_loop{{.+}}.omp_outlined{{.*}})
67 // CHECK-LABEL: define {{.+}}parallel_loop{{.+}}.omp_outlined{{.+}}
68 // CHECK: call {{.+}}__kmpc_for_static_init_4
69 // CHECK: omp.inner.for.body:
70 // CHECK: omp.loop.exit:
71 // CHECK-NEXT: call {{.+}}__kmpc_for_static_fini
72 // CHECK-NEXT: call {{.+}}__kmpc_barrier
75 // CHECK-LABEL: define {{.+}}parallel_loop_orphan{{.+}}
76 // CHECK: [[TMP0:%.*]] = call {{.+}}__kmpc_global_thread_num
77 // CHECK: call {{.+}}__kmpc_for_static_init_4
78 // CHECK: omp.inner.for.body:
79 // CHECK: omp.inner.for.end:
80 // CHECK: omp.loop.exit:
81 // CHECK-NEXT: call {{.+}}__kmpc_for_static_fini
82 // CHECK-NEXT: call {{.+}}__kmpc_barrier
85 // CHECK-LABEL: define {{.+}}teams_loop{{.+}}
86 // CHECK: call {{.+}}__kmpc_fork_teams({{.+}}teams_loop{{.+}}.omp_outlined{{.*}})
89 // CHECK-LABEL: define {{.+}}teams_loop{{.+}}.omp_outlined{{.+}}
90 // CHECK: call {{.+}}__kmpc_for_static_init_4
91 // CHECK: omp.inner.for.body:
92 // CHECK: omp.loop.exit:
93 // CHECK-NEXT: call {{.+}}__kmpc_for_static_fini
96 // CHECK-LABEL: define {{.+}}thread_loop{{.+}}
97 // CHECK: call {{.+}}__kmpc_fork_call({{.+}}thread_loop{{.+}}.omp_outlined{{.*}})
100 // CHECK-LABEL: define {{.+}}thread_loop{{.+}}.omp_outlined{{.+}}
101 // CHECK: omp.inner.for.body:
102 // CHECK: omp.inner.for.end:
105 // CHECK-LABEL: define {{.+}}thread_loop_orphan{{.+}}
106 // CHECK: omp.inner.for.cond:
107 // CHECK: omp.inner.for.body:
108 // CHECK: omp.inner.for.end:
111 // CHECK-LABEL: define {{.+}}main{{.+}}
112 // CHECK: call {{.+}}parallel_loop{{.+}}()
113 // CHECK-NEXT: call {{.+}}parallel_loop_orphan{{.+}}()
114 // CHECK-NEXT: call {{.+}}teams_loop{{.+}}()
115 // CHECK-NEXT: call {{.+}}thread_loop{{.+}}()
116 // CHECK-NEXT: call {{.+}}thread_loop_orphan{{.+}}()