xref: /llvm-project/flang/test/Lower/OpenMP/wsloop-nonmonotonic.f90 (revision 937cbce14c9aa956342a9c818c26a8a557802843)
1! This test checks lowering of OpenMP DO Directive(Worksharing) with
2! non-monotonic schedule modifier.
3
4! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
5
6program wsloop_dynamic
7  integer :: i
8!CHECK-LABEL: func @_QQmain()
9
10
11!$OMP PARALLEL
12!CHECK:  omp.parallel {
13
14!$OMP DO SCHEDULE(nonmonotonic:dynamic)
15!CHECK:     %[[I_REF:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}}
16!CHECK:     %[[ALLOCA_IV:.*]]:2 = hlfir.declare %[[I_REF]] {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
17!CHECK:     %[[WS_LB:.*]] = arith.constant 1 : i32
18!CHECK:     %[[WS_UB:.*]] = arith.constant 9 : i32
19!CHECK:     %[[WS_STEP:.*]] = arith.constant 1 : i32
20!CHECK:     omp.wsloop nowait schedule(dynamic, nonmonotonic) {
21!CHECK-NEXT:  omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) {
22!CHECK:         fir.store %[[I]] to %[[ALLOCA_IV]]#1 : !fir.ref<i32>
23
24  do i=1, 9
25    print*, i
26!CHECK:         %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput
27!CHECK:         %[[LOAD:.*]] = fir.load %[[ALLOCA_IV]]#0 : !fir.ref<i32>
28!CHECK:         fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[LOAD]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
29!CHECK:         fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) {{.*}}: (!fir.ref<i8>) -> i32
30  end do
31!CHECK:         omp.yield
32!CHECK:       }
33!CHECK:     }
34!CHECK:     omp.terminator
35!CHECK:   }
36
37!$OMP END DO NOWAIT
38!$OMP END PARALLEL
39end
40