1 ! This test checks lowering of OpenMP DO Directive (Worksharing).
3 ! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
5 !CHECK-LABEL: func @_QPsimple_loop()
10 ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}}
11 ! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loopEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
12 ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
13 ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
14 ! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
16 ! CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) {
19 ! CHECK: fir.store %[[I]] to %[[IV_DECL:.*]]#1 : !fir.ref<i32>
20 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32>
21 ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
26 ! CHECK: omp.terminator
30 !CHECK-LABEL: func @_QPsimple_loop_with_step()
31 subroutine simple_loop_with_step
35 ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}}
36 ! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loop_with_stepEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
37 ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
38 ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
39 ! CHECK: %[[WS_STEP:.*]] = arith.constant 2 : i32
41 ! CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) {
42 ! CHECK: fir.store %[[I]] to %[[IV_DECL]]#1 : !fir.ref<i32>
43 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32>
46 ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
51 ! CHECK: omp.terminator
55 !CHECK-LABEL: func @_QPloop_with_schedule_nowait()
56 subroutine loop_with_schedule_nowait
60 ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}}
61 ! CHECK: %[[IV_DECL:.*]]:2 = hlfir.declare %[[ALLOCA_IV]] {uniq_name = "_QFloop_with_schedule_nowaitEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
62 ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
63 ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
64 ! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
65 ! CHECK: omp.wsloop nowait schedule(runtime) {
66 ! CHECK-NEXT: omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) {
67 !$OMP DO SCHEDULE(runtime)
69 ! CHECK: fir.store %[[I]] to %[[IV_DECL]]#1 : !fir.ref<i32>
70 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[IV_DECL]]#0 : !fir.ref<i32>
71 ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
76 ! CHECK: omp.terminator