xref: /llvm-project/flang/test/Lower/OpenMP/wsloop-monotonic.f90 (revision 937cbce14c9aa956342a9c818c26a8a557802843)
15b66987cSKiran Chandramohan! This test checks lowering of OpenMP DO Directive (Worksharing) with
25b66987cSKiran Chandramohan! monotonic schedule modifier.
35b66987cSKiran Chandramohan
45b66987cSKiran Chandramohan! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
55b66987cSKiran Chandramohan
65b66987cSKiran Chandramohanprogram wsloop_dynamic
75b66987cSKiran Chandramohan  integer :: i
85b66987cSKiran Chandramohan!CHECK-LABEL: func @_QQmain()
95b66987cSKiran Chandramohan
105b66987cSKiran Chandramohan!$OMP PARALLEL
115b66987cSKiran Chandramohan!CHECK:  omp.parallel {
125b66987cSKiran Chandramohan
135b66987cSKiran Chandramohan!$OMP DO SCHEDULE(monotonic:dynamic)
14*937cbce1SKareem Ergawy!CHECK:     %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}}
155b66987cSKiran Chandramohan!CHECK:     %[[WS_LB:.*]] = arith.constant 1 : i32
165b66987cSKiran Chandramohan!CHECK:     %[[WS_UB:.*]] = arith.constant 9 : i32
175b66987cSKiran Chandramohan!CHECK:     %[[WS_STEP:.*]] = arith.constant 1 : i32
18*937cbce1SKareem Ergawy!CHECK:     omp.wsloop nowait schedule(dynamic, monotonic) {
19ca4dbc27SSergio Afonso!CHECK-NEXT:  omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_LB]]) to (%[[WS_UB]]) inclusive step (%[[WS_STEP]]) {
205b66987cSKiran Chandramohan!CHECK:         fir.store %[[I]] to %[[ALLOCA_IV:.*]]#1 : !fir.ref<i32>
215b66987cSKiran Chandramohan
225b66987cSKiran Chandramohan  do i=1, 9
235b66987cSKiran Chandramohan    print*, i
245b66987cSKiran Chandramohan!CHECK:         %[[RTBEGIN:.*]] = fir.call @_FortranAioBeginExternalListOutput
255b66987cSKiran Chandramohan!CHECK:         %[[LOAD:.*]] = fir.load %[[ALLOCA_IV]]#0 : !fir.ref<i32>
265b66987cSKiran Chandramohan!CHECK:         fir.call @_FortranAioOutputInteger32(%[[RTBEGIN]], %[[LOAD]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
275b66987cSKiran Chandramohan!CHECK:         fir.call @_FortranAioEndIoStatement(%[[RTBEGIN]]) {{.*}}: (!fir.ref<i8>) -> i32
285b66987cSKiran Chandramohan  end do
295b66987cSKiran Chandramohan!CHECK:         omp.yield
305b66987cSKiran Chandramohan!CHECK:     omp.terminator
315b66987cSKiran Chandramohan!CHECK:   }
325b66987cSKiran Chandramohan
335b66987cSKiran Chandramohan!$OMP END DO NOWAIT
345b66987cSKiran Chandramohan!$OMP END PARALLEL
355b66987cSKiran Chandramohanend
36