1 ! This test checks lowering of OpenMP DO Directive (Worksharing).
3 ! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
5 !CHECK-LABEL: func @_QPsimple_loop()
10 ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned}
11 ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
12 ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
13 ! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
14 ! CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
17 ! CHECK: fir.store %[[I]] to %[[ALLOCA_IV:.*]] : !fir.ref<i32>
18 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[ALLOCA_IV]] : !fir.ref<i32>
19 ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
24 ! CHECK: omp.terminator
28 !CHECK-LABEL: func @_QPsimple_loop_with_step()
29 subroutine simple_loop_with_step
33 ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned}
34 ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
35 ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
36 ! CHECK: %[[WS_STEP:.*]] = arith.constant 2 : i32
37 ! CHECK: omp.wsloop for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
38 ! CHECK: fir.store %[[I]] to %[[ALLOCA_IV]] : !fir.ref<i32>
39 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[ALLOCA_IV]] : !fir.ref<i32>
42 ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
47 ! CHECK: omp.terminator
51 !CHECK-LABEL: func @_QPloop_with_schedule_nowait()
52 subroutine loop_with_schedule_nowait
56 ! CHECK: %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned}
57 ! CHECK: %[[WS_LB:.*]] = arith.constant 1 : i32
58 ! CHECK: %[[WS_UB:.*]] = arith.constant 9 : i32
59 ! CHECK: %[[WS_STEP:.*]] = arith.constant 1 : i32
60 ! CHECK: omp.wsloop schedule(runtime) nowait for (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]])
61 !$OMP DO SCHEDULE(runtime)
63 ! CHECK: fir.store %[[I]] to %[[ALLOCA_IV]] : !fir.ref<i32>
64 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[ALLOCA_IV]] : !fir.ref<i32>
65 ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
70 ! CHECK: omp.terminator