xref: /llvm-project/flang/test/Lower/OpenMP/hlfir-wsloop.f90 (revision 937cbce14c9aa956342a9c818c26a8a557802843)
1! This test checks lowering of OpenMP DO Directive with HLFIR.
2
3! RUN: bbc -hlfir -fopenmp -emit-fir %s -o - | FileCheck %s
4! RUN: %flang_fc1 -emit-fir -flang-experimental-hlfir -fopenmp %s -o - | FileCheck %s
5
6!CHECK-LABEL: func @_QPsimple_loop()
7subroutine simple_loop
8  integer :: i
9  ! CHECK-DAG:     %[[WS_ST:.*]] = arith.constant 1 : i32
10  ! CHECK-DAG:     %[[WS_END:.*]] = arith.constant 9 : i32
11  ! CHECK:  omp.parallel
12  !$OMP PARALLEL
13  ! CHECK-DAG:     %[[ALLOCA_IV:.*]] = fir.alloca i32 {{{.*}}, pinned, {{.*}}}
14  ! CHECK:         %[[IV:.*]]    = fir.declare %[[ALLOCA_IV]] {uniq_name = "_QFsimple_loopEi"} : (!fir.ref<i32>) -> !fir.ref<i32>
15  ! CHECK:         omp.wsloop {
16  ! CHECK-NEXT:      omp.loop_nest (%[[I:.*]]) : i32 = (%[[WS_ST]]) to (%[[WS_END]]) inclusive step (%[[WS_ST]]) {
17  !$OMP DO
18  do i=1, 9
19  ! CHECK:             fir.store %[[I]] to %[[IV:.*]] : !fir.ref<i32>
20  ! CHECK:             %[[LOAD_IV:.*]] = fir.load %[[IV]] : !fir.ref<i32>
21  ! CHECK:             fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
22    print*, i
23  end do
24  ! CHECK:             omp.yield
25  !$OMP END DO
26  ! CHECK:         omp.terminator
27  !$OMP END PARALLEL
28end subroutine
29