Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / OpenMP / wsloop-chunks.f90
blob99b0cf0f1298e3dbe49f6924e32c31b158c61820
1 ! This test checks that chunk size is passed correctly when lowering of
2 ! OpenMP DO Directive(Worksharing) with chunk size
4 ! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
6 program wsloop
7 integer :: i
8 integer :: chunk
10 ! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "wsloop"} {
11 ! CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "chunk", uniq_name = "_QFEchunk"}
13 !$OMP DO SCHEDULE(static, 4)
15 do i=1, 9
16 print*, i
18 ! CHECK: %[[VAL_2:.*]] = arith.constant 1 : i32
19 ! CHECK: %[[VAL_3:.*]] = arith.constant 9 : i32
20 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
21 ! CHECK: %[[VAL_5:.*]] = arith.constant 4 : i32
22 ! CHECK: omp.wsloop schedule(static = %[[VAL_5]] : i32) nowait for (%[[ARG0:.*]]) : i32 = (%[[VAL_2]]) to (%[[VAL_3]]) inclusive step (%[[VAL_4]]) {
23 ! CHECK: fir.store %[[ARG0]] to %[[STORE_IV:.*]] : !fir.ref<i32>
24 ! CHECK: %[[LOAD_IV:.*]] = fir.load %[[STORE_IV]] : !fir.ref<i32>
25 ! CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[LOAD_IV]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
26 ! CHECK: omp.yield
27 ! CHECK: }
29 end do
30 !$OMP END DO NOWAIT
31 !$OMP DO SCHEDULE(static, 2+2)
33 do i=1, 9
34 print*, i*2
36 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i32
37 ! CHECK: %[[VAL_15:.*]] = arith.constant 9 : i32
38 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : i32
39 ! CHECK: %[[VAL_17:.*]] = arith.constant 4 : i32
40 ! CHECK: omp.wsloop schedule(static = %[[VAL_17]] : i32) nowait for (%[[ARG1:.*]]) : i32 = (%[[VAL_14]]) to (%[[VAL_15]]) inclusive step (%[[VAL_16]]) {
41 ! CHECK: fir.store %[[ARG1]] to %[[STORE_IV1:.*]] : !fir.ref<i32>
42 ! CHECK: %[[VAL_24:.*]] = arith.constant 2 : i32
43 ! CHECK: %[[LOAD_IV1:.*]] = fir.load %[[STORE_IV1]] : !fir.ref<i32>
44 ! CHECK: %[[VAL_25:.*]] = arith.muli %[[VAL_24]], %[[LOAD_IV1]] : i32
45 ! CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[VAL_25]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
46 ! CHECK: omp.yield
47 ! CHECK: }
49 end do
50 !$OMP END DO NOWAIT
51 chunk = 6
52 !$OMP DO SCHEDULE(static, chunk)
54 do i=1, 9
55 print*, i*3
56 end do
57 !$OMP END DO NOWAIT
58 ! CHECK: %[[VAL_28:.*]] = arith.constant 6 : i32
59 ! CHECK: fir.store %[[VAL_28]] to %[[VAL_0]] : !fir.ref<i32>
60 ! CHECK: %[[VAL_29:.*]] = arith.constant 1 : i32
61 ! CHECK: %[[VAL_30:.*]] = arith.constant 9 : i32
62 ! CHECK: %[[VAL_31:.*]] = arith.constant 1 : i32
63 ! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_0]] : !fir.ref<i32>
64 ! CHECK: omp.wsloop schedule(static = %[[VAL_32]] : i32) nowait for (%[[ARG2:.*]]) : i32 = (%[[VAL_29]]) to (%[[VAL_30]]) inclusive step (%[[VAL_31]]) {
65 ! CHECK: fir.store %[[ARG2]] to %[[STORE_IV2:.*]] : !fir.ref<i32>
66 ! CHECK: %[[VAL_39:.*]] = arith.constant 3 : i32
67 ! CHECK: %[[LOAD_IV2:.*]] = fir.load %[[STORE_IV2]] : !fir.ref<i32>
68 ! CHECK: %[[VAL_40:.*]] = arith.muli %[[VAL_39]], %[[LOAD_IV2]] : i32
69 ! CHECK: {{.*}} = fir.call @_FortranAioOutputInteger32({{.*}}, %[[VAL_40]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
70 ! CHECK: omp.yield
71 ! CHECK: }
72 ! CHECK: return
73 ! CHECK: }
75 end