Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / loop_bind_enclosed.cpp
blob286ca1d58b5f1dbd68b26ccce05e2bb72b19ec3d
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
5 #define NNN 50
6 int aaa[NNN];
8 void parallel_taskgroup_loop() {
9 #pragma omp parallel
11 #pragma omp taskgroup
12 for (int i = 0 ; i < 2 ; i++) {
13 #pragma omp loop
14 for (int j = 0 ; j < NNN ; j++) {
15 aaa[j] = j*NNN;
21 void parallel_taskwait_loop() {
22 #pragma omp parallel
24 #pragma omp taskwait
25 for (int i = 0 ; i < 2 ; i++) {
26 #pragma omp loop
27 for (int j = 0 ; j < NNN ; j++) {
28 aaa[j] = j*NNN;
34 void parallel_single_loop() {
35 #pragma omp parallel
37 for (int i = 0 ; i < 2 ; i++) {
38 #pragma omp single
39 #pragma omp loop
40 for (int j = 0 ; j < NNN ; j++) {
41 aaa[j] = j*NNN;
47 void parallel_order_loop() {
48 #pragma omp parallel
50 #pragma omp for order(concurrent)
52 for (int i = 0 ; i < 2 ; i++) {
53 #pragma omp loop
54 for (int j = 0 ; j < NNN ; j++) {
55 aaa[j] = j*NNN;
63 void parallel_cancel_loop(bool flag) {
64 #pragma omp ordered
65 for (int i = 0 ; i < 2 ; i++) {
66 #pragma omp parallel
68 #pragma omp cancel parallel if(flag)
69 aaa[0] = 0;
70 #pragma omp loop bind(parallel)
71 for (int j = 0 ; j < NNN ; j++) {
72 aaa[j] = j*NNN;
78 int
79 main(int argc, char *argv[]) {
80 parallel_taskgroup_loop();
81 parallel_taskwait_loop();
82 parallel_single_loop();
83 parallel_order_loop();
84 parallel_cancel_loop(true);
85 parallel_cancel_loop(false);
87 return 0;
89 // CHECK-LABEL: define {{.+}}parallel_taskgroup_loop{{.+}} {
90 // CHECK: call {{.+}}__kmpc_fork_call({{.+}}parallel_taskgroup_loop{{.+}}.omp_outlined{{.*}}
93 // CHECK-LABEL: define {{.+}}parallel_taskgroup_loop{{.+}}.omp_outlined{{.+}} {
94 // CHECK: call {{.+}}__kmpc_taskgroup
95 // CHECK: for.body:
96 // CHECK: omp.inner.for.cond:
97 // CHECK: omp.inner.for.body:
98 // CHECK: omp.inner.for.inc:
99 // CHECK: omp.inner.for.end:
100 // CHECK: for.end:
101 // CHECK: call {{.+}}__kmpc_end_taskgroup
104 // CHECK-LABEL: define {{.+}}parallel_taskwait_loop{{.+}} {
105 // CHECK: call {{.+}}__kmpc_fork_call({{.+}}parallel_taskwait_loop{{.+}}.omp_outlined{{.*}})
108 // CHECK-LABEL: define {{.+}}parallel_taskwait_loop{{.+}}.omp_outlined{{.+}} {
109 // CHECK: [[TMP2:%.*]] = {{.+}}__kmpc_omp_taskwait
110 // CHECK: for.cond:
111 // CHECK: for.body:
112 // CHECK: {{.+}}__kmpc_for_static_init_4
113 // CHECK: omp.inner.for.cond:
114 // CHECK: omp.inner.for.body:
115 // CHECK: omp.body.continue:
116 // CHECK: omp.inner.for.inc:
117 // CHECK: omp.inner.for.end:
118 // CHECK: omp.loop.exit:
119 // CHECK: call void @__kmpc_for_static_fini
120 // CHECK: call void @__kmpc_barrier
121 // CHECK: for.end:
124 // CHECK-LABEL: define {{.+}}parallel_single_loop{{.+}} {
125 // CHECK: call {{.+}}__kmpc_fork_call({{.+}}parallel_single_loop{{.+}}.omp_outlined{{.*}})
128 // CHECK-LABEL: define {{.+}}parallel_single_loop{{.+}}.omp_outlined{{.+}} {
129 // CHECK: for.body:
130 // CHECK: [[TMP3:%.*]] = call {{.+}}__kmpc_single
131 // CHECK: omp.inner.for.end:
132 // CHECK: call {{.+}}__kmpc_end_single
133 // CHECK: omp_if.end:
134 // CHECK: call {{.+}}__kmpc_barrier
135 // CHECK: for.end:
138 // CHECK-LABEL: define {{.+}}parallel_order_loop{{.+}} {
139 // CHECK: call {{.+}}__kmpc_fork_call({{.+}}parallel_order_loop{{.+}}.omp_outlined{{.*}})
142 // CHECK-LABEL: define {{.+}}parallel_order_loop{{.+}}.omp_outlined{{.+}} {
143 // CHECK: call {{.+}}__kmpc_for_static_init_4
144 // CHECK: omp.inner.for.body:
145 // CHECK: omp.loop.exit:
146 // CHECK: call {{.+}}__kmpc_for_static_fini
147 // CHECK: call {{.+}}__kmpc_barrier
150 // CHECK-LABEL: define {{.+}}parallel_cancel_loop{{.+}} {
151 // CHECK: call {{.+}}__kmpc_ordered
152 // CHECK: for.body:
153 // CHECK: call {{.+}}__kmpc_fork_call({{.+}}parallel_cancel_loop{{.+}}.omp_outlined{{.+}})
154 // CHECK: for.end:
155 // CHECK: call {{.+}}__kmpc_end_ordered
158 // CHECK-LABEL: define {{.+}}parallel_cancel_loop{{.+}}.omp_outlined{{.+}} {
159 // CHECK: omp_if.then:
160 // CHECK: [[TMP4:%.*]] = call {{.+}}__kmpc_cancel
161 // CHECK: .cancel.exit:
162 // CHECK: [[TMP8:%.*]] = call {{.+}}__kmpc_cancel_barrier
163 // CHECK: omp_if.end:
164 // CHECK: call {{.+}}__kmpc_for_static_init_4
165 // CHECK: omp.inner.for.body:
166 // CHECK: omp.loop.exit:
167 // CHECK: call {{.+}}__kmpc_for_static_fini
168 // CHECK: [[TMP24:%.*]] = call {{.+}}__kmpc_cancel_barrier
169 // CHECK: .cancel.continue5:
172 // CHECK-LABEL: define {{.+}}@main{{.+}} {
173 // CHECK: call {{.+}}parallel_taskgroup_loop{{.+}}()
174 // CHECK-NEXT: call {{.+}}parallel_taskwait_loop{{.+}}()
175 // CHECK-NEXT: call {{.+}}parallel_single_loop{{.+}}()
176 // CHECK-NEXT: call {{.+}}parallel_order_loop{{.+}}()
177 // CHECK-NEXT: call {{.+}}parallel_cancel_loop{{.+}}({{.+}}true)
178 // CHECK-NEXT: call {{.+}}parallel_cancel_loop{{.+}}({{.+}}false)