@@ -235,3 +235,54 @@ llvm.func @omp_teams_num_teams_and_thread_limit(%numTeamsLower: i32, %numTeamsUp
235
235
// CHECK: define internal void [[OUTLINED_FN]](ptr {{.+}}, ptr {{.+}})
236
236
// CHECK: call void @duringTeams()
237
237
// CHECK: ret void
238
+
239
+ // -----
240
+
241
+ llvm.func @beforeTeams ()
242
+ llvm.func @duringTeams ()
243
+ llvm.func @afterTeams ()
244
+
245
+ // CHECK-LABEL: @teams_if
246
+ // CHECK-SAME: (i1 [[ARG:.+]])
247
+ llvm.func @teams_if (%arg : i1 ) {
248
+ // CHECK-NEXT: call void @beforeTeams()
249
+ llvm.call @beforeTeams () : () -> ()
250
+ // If the condition is true, then the value of bounds is zero - which basically means "implementation-defined".
251
+ // The runtime sees zero and sets a default value of number of teams. This behavior is according to the standard.
252
+ // The same is true for `thread_limit`.
253
+ // CHECK: [[NUM_TEAMS_UPPER:%.+]] = select i1 [[ARG]], i32 0, i32 1
254
+ // CHECK: [[NUM_TEAMS_LOWER:%.+]] = select i1 [[ARG]], i32 0, i32 1
255
+ // CHECK: call void @__kmpc_push_num_teams_51(ptr {{.+}}, i32 {{.+}}, i32 [[NUM_TEAMS_LOWER]], i32 [[NUM_TEAMS_UPPER]], i32 0)
256
+ // CHECK: call void {{.+}} @__kmpc_fork_teams({{.+}})
257
+ omp.teams if (%arg ) {
258
+ llvm.call @duringTeams () : () -> ()
259
+ omp.terminator
260
+ }
261
+ // CHECK: call void @afterTeams()
262
+ llvm.call @afterTeams () : () -> ()
263
+ llvm.return
264
+ }
265
+
266
+ // -----
267
+
268
+ llvm.func @beforeTeams ()
269
+ llvm.func @duringTeams ()
270
+ llvm.func @afterTeams ()
271
+
272
+ // CHECK-LABEL: @teams_if_with_num_teams
273
+ // CHECK-SAME: (i1 [[CONDITION:.+]], i32 [[NUM_TEAMS_LOWER:.+]], i32 [[NUM_TEAMS_UPPER:.+]], i32 [[THREAD_LIMIT:.+]])
274
+ llvm.func @teams_if_with_num_teams (%condition: i1 , %numTeamsLower: i32 , %numTeamsUpper: i32 , %threadLimit: i32 ) {
275
+ // CHECK: call void @beforeTeams()
276
+ llvm.call @beforeTeams () : () -> ()
277
+ // CHECK: [[NUM_TEAMS_UPPER_NEW:%.+]] = select i1 [[CONDITION]], i32 [[NUM_TEAMS_UPPER]], i32 1
278
+ // CHECK: [[NUM_TEAMS_LOWER_NEW:%.+]] = select i1 [[CONDITION]], i32 [[NUM_TEAMS_LOWER]], i32 1
279
+ // CHECK: call void @__kmpc_push_num_teams_51(ptr {{.+}}, i32 {{.+}}, i32 [[NUM_TEAMS_LOWER_NEW]], i32 [[NUM_TEAMS_UPPER_NEW]], i32 [[THREAD_LIMIT]])
280
+ // CHECK: call void {{.+}} @__kmpc_fork_teams({{.+}})
281
+ omp.teams if (%condition ) num_teams (%numTeamsLower: i32 to %numTeamsUpper: i32 ) thread_limit (%threadLimit: i32 ) {
282
+ llvm.call @duringTeams () : () -> ()
283
+ omp.terminator
284
+ }
285
+ // CHECK: call void @afterTeams()
286
+ llvm.call @afterTeams () : () -> ()
287
+ llvm.return
288
+ }
0 commit comments