1 ! RUN: bbc -emit-fir -o - %s | FileCheck %s
3 ! CHECK-LABEL: loop_test
5 ! CHECK: %[[VAL_2:.*]] = fir.alloca i16 {bindc_name = "i"}
6 ! CHECK: %[[VAL_3:.*]] = fir.alloca i16 {bindc_name = "i"}
7 ! CHECK: %[[VAL_4:.*]] = fir.alloca i16 {bindc_name = "i"}
8 ! CHECK: %[[VAL_5:.*]] = fir.alloca i8 {bindc_name = "k"}
9 ! CHECK: %[[VAL_6:.*]] = fir.alloca i8 {bindc_name = "j"}
10 ! CHECK: %[[VAL_7:.*]] = fir.alloca i8 {bindc_name = "i"}
11 ! CHECK: %[[VAL_8:.*]] = fir.alloca i32 {bindc_name = "k"}
12 ! CHECK: %[[VAL_9:.*]] = fir.alloca i32 {bindc_name = "j"}
13 ! CHECK: %[[VAL_10:.*]] = fir.alloca i32 {bindc_name = "i"}
14 ! CHECK: %[[VAL_11:.*]] = fir.alloca !fir.array<5x5x5xi32> {bindc_name = "a", uniq_name = "_QFloop_testEa"}
15 ! CHECK: %[[VAL_12:.*]] = fir.alloca i32 {bindc_name = "asum", uniq_name = "_QFloop_testEasum"}
16 ! CHECK: %[[VAL_13:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFloop_testEi"}
17 ! CHECK: %[[VAL_14:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFloop_testEj"}
18 ! CHECK: %[[VAL_15:.*]] = fir.alloca i32 {bindc_name = "k", uniq_name = "_QFloop_testEk"}
19 ! CHECK: %[[VAL_16:.*]] = fir.alloca f32 {bindc_name = "x", uniq_name = "_QFloop_testEx"}
20 ! CHECK: %[[VAL_17:.*]] = fir.alloca i32 {bindc_name = "xsum", uniq_name = "_QFloop_testExsum"}
22 integer(4) :: a(5,5,5), i
, j
, k
, asum
, xsum
28 ! CHECK-COUNT-3: fir.do_loop {{.*}} unordered
29 do concurrent (i
=1:5, j
=1:5, k
=1:5) ! shared(a)
30 ! CHECK: fir.coordinate_of
33 ! CHECK: fir.call @_FortranAioBeginExternalListOutput
36 ! CHECK-COUNT-3: fir.do_loop {{.*}} unordered
38 do concurrent (integer(1)::i
=1:5, j
=1:5, k
=1:5, i
.ne
.j
.and
. k
.ne
.3) shared(a
)
39 ! CHECK-COUNT-2: fir.coordinate_of
40 a(i
,j
,k
) = a(i
,j
,k
) + 1
43 ! CHECK-COUNT-3: fir.do_loop {{[^un]*}} -> (index, i32)
48 ! CHECK: fir.coordinate_of
49 asum
= asum
+ a(i
,j
,k
)
53 ! CHECK: fir.call @_FortranAioBeginExternalListOutput
54 print*, 'B:', i
, j
, k
, '-', asum
56 ! CHECK: fir.do_loop {{.*}} unordered
57 ! CHECK-COUNT-2: fir.if
58 do concurrent (integer(2)::i
=1:5, i
.ne
.3)
59 if (i
.eq
.2 .or
. i
.eq
.4) goto 5 ! fir.if
60 ! CHECK: fir.call @_FortranAioBeginExternalListOutput
65 ! CHECK: fir.do_loop {{.*}} unordered
66 ! CHECK-COUNT-2: fir.if
67 do concurrent (integer(2)::i
=1:5, i
.ne
.3)
68 if (i
.eq
.2 .or
. i
.eq
.4) then ! fir.if
71 ! CHECK: fir.call @_FortranAioBeginExternalListOutput
76 ! CHECK-NOT: fir.do_loop
78 do concurrent (integer(2)::i
=1:5, i
.ne
.3)
80 ! CHECK: fir.call @_FortranAioBeginExternalListOutput
86 ! CHECK-NOT: fir.do_loop
90 ! CHECK: fir.call @_FortranAioBeginExternalFormattedOutput
91 print '(" F:",X,F3.1,A,I2)', x
, ' -', xsum
92 end subroutine loop_test
94 ! CHECK-LABEL: c.func @_QPlis
96 ! CHECK-DAG: fir.alloca i32 {bindc_name = "m"}
97 ! CHECK-DAG: fir.alloca i32 {bindc_name = "j"}
98 ! CHECK-DAG: fir.alloca i32 {bindc_name = "i"}
99 ! CHECK-DAG: fir.alloca i8 {bindc_name = "i"}
100 ! CHECK-DAG: fir.alloca i32 {bindc_name = "j", uniq_name = "_QFlisEj"}
101 ! CHECK-DAG: fir.alloca i32 {bindc_name = "k", uniq_name = "_QFlisEk"}
102 ! CHECK-DAG: fir.alloca !fir.box<!fir.ptr<!fir.array<?x?x?xi32>>> {bindc_name = "p", uniq_name = "_QFlisEp"}
103 ! CHECK-DAG: fir.alloca !fir.array<?x?x?xi32>, %{{.*}}, %{{.*}}, %{{.*}} {bindc_name = "a", fir.target, uniq_name = "_QFlisEa"}
104 ! CHECK-DAG: fir.alloca !fir.array<?x?xi32>, %{{.*}}, %{{.*}} {bindc_name = "r", uniq_name = "_QFlisEr"}
105 ! CHECK-DAG: fir.alloca !fir.array<?x?xi32>, %{{.*}}, %{{.*}} {bindc_name = "s", uniq_name = "_QFlisEs"}
106 ! CHECK-DAG: fir.alloca !fir.array<?x?xi32>, %{{.*}}, %{{.*}} {bindc_name = "t", uniq_name = "_QFlisEt"}
107 integer, target
:: a(n
,n
,n
) ! operand via p
108 integer :: r(n
,n
) ! result, unspecified locality
109 integer :: s(n
,n
) ! shared locality
110 integer :: t(n
,n
) ! local locality
111 integer, pointer :: p(:,:,:) ! local_init locality
114 ! CHECK: fir.do_loop %arg1 = %c0{{.*}} to %{{.*}} step %c1{{.*}} unordered iter_args(%arg2 = %{{.*}}) -> (!fir.array<?x?xi32>) {
115 ! CHECK: fir.do_loop %arg3 = %c0{{.*}} to %{{.*}} step %c1{{.*}} unordered iter_args(%arg4 = %arg2) -> (!fir.array<?x?xi32>) {
120 ! CHECK: fir.do_loop %arg1 = %{{.*}} to %{{.*}} step %{{.*}} unordered {
121 ! CHECK: fir.do_loop %arg2 = %{{.*}} to %{{.*}} step %c1{{.*}} iter_args(%arg3 = %{{.*}}) -> (index, i32) {
124 do concurrent (integer(kind
=1)::i
=n
:1:-1)
131 ! CHECK: fir.do_loop %arg1 = %{{.*}} to %{{.*}} step %c1{{.*}} unordered {
132 ! CHECK: fir.do_loop %arg2 = %{{.*}} to %{{.*}} step %c1{{.*}} unordered {
133 ! CHECK: fir.if %{{.*}} {
134 ! CHECK: %[[V_95:[0-9]+]] = fir.alloca !fir.array<?x?xi32>, %{{.*}}, %{{.*}} {bindc_name = "t", pinned, uniq_name = "_QFlisEt"}
135 ! CHECK: %[[V_96:[0-9]+]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?x?xi32>>> {bindc_name = "p", pinned, uniq_name = "_QFlisEp"}
136 ! CHECK: fir.store %{{.*}} to %[[V_96]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?x?xi32>>>>
137 ! CHECK: fir.do_loop %arg3 = %{{.*}} to %{{.*}} step %c1{{.*}} iter_args(%arg4 = %{{.*}}) -> (index, i32) {
138 ! CHECK: fir.do_loop %arg5 = %{{.*}} to %{{.*}} step %c1{{.*}} unordered {
139 ! CHECK: fir.load %[[V_96]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?x?xi32>>>>
140 ! CHECK: fir.convert %[[V_95]] : (!fir.ref<!fir.array<?x?xi32>>) -> !fir.ref<!fir.array<?xi32>>
143 ! CHECK: fir.convert %[[V_95]] : (!fir.ref<!fir.array<?x?xi32>>) -> !fir.ref<!fir.array<?xi32>>
147 do concurrent (i
=1:n
,j
=1:n
,i
.ne
.j
) local(t
) local_init(p
) shared(s
)
149 do concurrent (m
=1:n
)
153 r(i
,j
) = t(i
,j
) + s(i
,j
)
156 print*, sum(r
) ! n=6 -> 210
159 ! CHECK-LABEL: print_nothing
160 subroutine print_nothing(k1
, k2
)
162 ! CHECK: br [[header:\^bb[0-9]+]]
165 print*, k1
, k2
! no output
167 ! CHECK: br [[header]]
174 call print_nothing(2, 2)