Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / OpenMP / wsloop.f90
blob2c00d1a9fddae86e5ca03dc9028f55885e304fb2
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()
6 subroutine simple_loop
7 integer :: i
8 ! CHECK: omp.parallel
9 !$OMP PARALLEL
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]])
15 !$OMP DO
16 do i=1, 9
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
20 print*, i
21 end do
22 ! CHECK: omp.yield
23 !$OMP END DO
24 ! CHECK: omp.terminator
25 !$OMP END PARALLEL
26 end subroutine
28 !CHECK-LABEL: func @_QPsimple_loop_with_step()
29 subroutine simple_loop_with_step
30 integer :: i
31 ! CHECK: omp.parallel
32 !$OMP PARALLEL
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>
40 !$OMP DO
41 do i=1, 9, 2
42 ! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
43 print*, i
44 end do
45 ! CHECK: omp.yield
46 !$OMP END DO
47 ! CHECK: omp.terminator
48 !$OMP END PARALLEL
49 end subroutine
51 !CHECK-LABEL: func @_QPloop_with_schedule_nowait()
52 subroutine loop_with_schedule_nowait
53 integer :: i
54 ! CHECK: omp.parallel
55 !$OMP PARALLEL
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)
62 do i=1, 9
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
66 print*, i
67 end do
68 ! CHECK: omp.yield
69 !$OMP END DO NOWAIT
70 ! CHECK: omp.terminator
71 !$OMP END PARALLEL
72 end subroutine