@@ -265,3 +265,43 @@ omp.private {type = firstprivate} @_QFequivalenceEx_firstprivate_ptr_f32 : f32 c
265265// CHECK: store float %[[HOST_VAL]], ptr %[[PRIV_ALLOC]], align 4
266266// Test that we inlined the body of the parallel region.
267267// CHECK: store float 0x{{.*}}, ptr %[[PRIV_ALLOC]], align 4
268+
269+ // -----
270+
271+ omp.private {type = private } @_QFEi_private_i32 : i32
272+ llvm.func @_QPprivate_alloc_with_switch () {
273+ %0 = llvm.mlir.constant (1 : i32 ) : i32
274+ %1 = llvm.mlir.constant (30 : i32 ) : i32
275+ %2 = llvm.mlir.constant (1 : i64 ) : i64
276+ %3 = llvm.alloca %2 x i32 {bindc_name = " n" } : (i64 ) -> !llvm.ptr
277+ %4 = llvm.alloca %2 x i32 {bindc_name = " i" } : (i64 ) -> !llvm.ptr
278+ llvm.store %0 , %3 : i32 , !llvm.ptr
279+ %5 = llvm.load %3 : !llvm.ptr -> i32
280+ llvm.switch %5 : i32 , ^bb1 [
281+ 1 : ^bb1 ,
282+ 2 : ^bb2
283+ ]
284+ ^bb1 : // 2 preds: ^bb0, ^bb0
285+ omp.simd private (@_QFEi_private_i32 %4 -> %arg0 : !llvm.ptr ) {
286+ omp.loop_nest (%arg1 ) : i32 = (%0 ) to (%1 ) inclusive step (%0 ) {
287+ llvm.store %arg1 , %arg0 : i32 , !llvm.ptr
288+ omp.yield
289+ }
290+ }
291+ llvm.br ^bb2
292+ ^bb2 : // 2 preds: ^bb0, ^bb1
293+ llvm.return
294+ }
295+
296+ // CHECK-LABEL: define void @_QPprivate_alloc_with_switch() {
297+ // CHECK: br label %[[AFTER_ALLOCA_BLOCK:.*]]
298+ // CHECK: [[AFTER_ALLOCA_BLOCK]]:
299+ // CHECK: switch i32 %{{.*}}, label %[[PRIVATE_INIT_BLOCK:.*]] [
300+ // CHECK: i32 1, label %[[PRIVATE_INIT_BLOCK]]
301+ // CHECK: i32 2, label %[[EXIT_BLOCK:.*]]
302+ // CHECK: ]
303+ // CHECK: [[PRIVATE_INIT_BLOCK]]:
304+ // CHECK: omp.private.init:
305+ // CHECK: omp.simd.region:
306+ // CHECK: [[EXIT_BLOCK]]:
307+ // CHECK: ret void
0 commit comments