Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / do_loop.f90
blobf881cf6d8603702a01ac785ebb6bc5b0e47b3200
1 ! RUN: bbc -emit-fir -o - %s | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir -o - %s | FileCheck %s
4 ! Simple tests for structured ordered loops with loop-control.
5 ! Tests the structure of the loop, storage to index variable and return and
6 ! storage of the final value of the index variable.
8 ! Test a simple loop with the final value of the index variable read outside the loop
9 ! CHECK-LABEL: simple_loop
10 subroutine simple_loop
11 ! CHECK: %[[I_REF:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFsimple_loopEi"}
12 integer :: i
14 ! CHECK: %[[C1:.*]] = arith.constant 1 : i32
15 ! CHECK: %[[C1_CVT:.*]] = fir.convert %c1_i32 : (i32) -> index
16 ! CHECK: %[[C5:.*]] = arith.constant 5 : i32
17 ! CHECK: %[[C5_CVT:.*]] = fir.convert %c5_i32 : (i32) -> index
18 ! CHECK: %[[C1:.*]] = arith.constant 1 : index
19 ! CHECK: %[[LB:.*]] = fir.convert %[[C1_CVT]] : (index) -> i32
20 ! CHECK: %[[LI_RES:.*]]:2 = fir.do_loop %[[LI:[^ ]*]] =
21 ! CHECK-SAME: %[[C1_CVT]] to %[[C5_CVT]] step %[[C1]]
22 ! CHECK-SAME: iter_args(%[[IV:.*]] = %[[LB]]) -> (index, i32) {
23 do i=1,5
24 ! CHECK: fir.store %[[IV]] to %[[I_REF]] : !fir.ref<i32>
25 ! CHECK: %[[LI_NEXT:.*]] = arith.addi %[[LI]], %[[C1]] : index
26 ! CHECK: %[[STEPCAST:.*]] = fir.convert %[[C1]] : (index) -> i32
27 ! CHECK: %[[IVLOAD:.*]] = fir.load %[[I_REF]] : !fir.ref<i32>
28 ! CHECK: %[[IVINC:.*]] = arith.addi %[[IVLOAD]], %[[STEPCAST]] : i32
29 ! CHECK: fir.result %[[LI_NEXT]], %[[IVINC]] : index, i32
30 ! CHECK: }
31 end do
32 ! CHECK: fir.store %[[LI_RES]]#1 to %[[I_REF]] : !fir.ref<i32>
33 ! CHECK: %[[I:.*]] = fir.load %[[I_REF]] : !fir.ref<i32>
34 ! CHECK: %{{.*}} = fir.call @_FortranAioOutputInteger32(%{{.*}}, %[[I]]) {{.*}}: (!fir.ref<i8>, i32) -> i1
35 print *, i
36 end subroutine
38 ! Test a 2-nested loop with a body composed of a reduction. Values are read from a 2d array.
39 ! CHECK-LABEL: nested_loop
40 subroutine nested_loop
41 ! CHECK: %[[ARR_REF:.*]] = fir.alloca !fir.array<5x5xi32> {bindc_name = "arr", uniq_name = "_QFnested_loopEarr"}
42 ! CHECK: %[[ASUM_REF:.*]] = fir.alloca i32 {bindc_name = "asum", uniq_name = "_QFnested_loopEasum"}
43 ! CHECK: %[[I_REF:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFnested_loopEi"}
44 ! CHECK: %[[J_REF:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFnested_loopEj"}
45 integer :: asum, arr(5,5)
46 integer :: i, j
47 asum = 0
48 ! CHECK: %[[S_I:.*]] = arith.constant 1 : i32
49 ! CHECK: %[[S_I_CVT:.*]] = fir.convert %[[S_I]] : (i32) -> index
50 ! CHECK: %[[E_I:.*]] = arith.constant 5 : i32
51 ! CHECK: %[[E_I_CVT:.*]] = fir.convert %[[E_I]] : (i32) -> index
52 ! CHECK: %[[ST_I:.*]] = arith.constant 1 : index
53 ! CHECK: %[[I_LB:.*]] = fir.convert %[[S_I_CVT]] : (index) -> i32
54 ! CHECK: %[[I_RES:.*]]:2 = fir.do_loop %[[LI:[^ ]*]] =
55 ! CHECK-SAME: %[[S_I_CVT]] to %[[E_I_CVT]] step %[[ST_I]]
56 ! CHECK-SAME: iter_args(%[[I_IV:.*]] = %[[I_LB]]) -> (index, i32) {
57 do i=1,5
58 ! CHECK: fir.store %[[I_IV]] to %[[I_REF]] : !fir.ref<i32>
59 ! CHECK: %[[S_J:.*]] = arith.constant 1 : i32
60 ! CHECK: %[[S_J_CVT:.*]] = fir.convert %[[S_J]] : (i32) -> index
61 ! CHECK: %[[E_J:.*]] = arith.constant 5 : i32
62 ! CHECK: %[[E_J_CVT:.*]] = fir.convert %[[E_J]] : (i32) -> index
63 ! CHECK: %[[ST_J:.*]] = arith.constant 1 : index
64 ! CHECK: %[[J_LB:.*]] = fir.convert %[[S_J_CVT]] : (index) -> i32
65 ! CHECK: %[[J_RES:.*]]:2 = fir.do_loop %[[LJ:[^ ]*]] =
66 ! CHECK-SAME: %[[S_J_CVT]] to %[[E_J_CVT]] step %[[ST_J]]
67 ! CHECK-SAME: iter_args(%[[J_IV:.*]] = %[[J_LB]]) -> (index, i32) {
68 do j=1,5
69 ! CHECK: fir.store %[[J_IV]] to %[[J_REF]] : !fir.ref<i32>
70 ! CHECK: %[[ASUM:.*]] = fir.load %[[ASUM_REF]] : !fir.ref<i32>
71 ! CHECK: %[[I:.*]] = fir.load %[[I_REF]] : !fir.ref<i32>
72 ! CHECK: %[[I_CVT:.*]] = fir.convert %[[I]] : (i32) -> i64
73 ! CHECK: %[[C1_I:.*]] = arith.constant 1 : i64
74 ! CHECK: %[[I_INDX:.*]] = arith.subi %[[I_CVT]], %[[C1_I]] : i64
75 ! CHECK: %[[J:.*]] = fir.load %[[J_REF]] : !fir.ref<i32>
76 ! CHECK: %[[J_CVT:.*]] = fir.convert %[[J]] : (i32) -> i64
77 ! CHECK: %[[C1_J:.*]] = arith.constant 1 : i64
78 ! CHECK: %[[J_INDX:.*]] = arith.subi %[[J_CVT]], %[[C1_J]] : i64
79 ! CHECK: %[[ARR_IJ_REF:.*]] = fir.coordinate_of %[[ARR_REF]], %[[I_INDX]], %[[J_INDX]] : (!fir.ref<!fir.array<5x5xi32>>, i64, i64) -> !fir.ref<i32>
80 ! CHECK: %[[ARR_VAL:.*]] = fir.load %[[ARR_IJ_REF]] : !fir.ref<i32>
81 ! CHECK: %[[ASUM_NEW:.*]] = arith.addi %[[ASUM]], %[[ARR_VAL]] : i32
82 ! CHECK: fir.store %[[ASUM_NEW]] to %[[ASUM_REF]] : !fir.ref<i32>
83 asum = asum + arr(i,j)
84 ! CHECK: %[[LJ_NEXT:.*]] = arith.addi %[[LJ]], %[[ST_J]] : index
85 ! CHECK: %[[J_STEPCAST:.*]] = fir.convert %[[ST_J]] : (index) -> i32
86 ! CHECK: %[[J_IVLOAD:.*]] = fir.load %[[J_REF]] : !fir.ref<i32>
87 ! CHECK: %[[J_IVINC:.*]] = arith.addi %[[J_IVLOAD]], %[[J_STEPCAST]] : i32
88 ! CHECK: fir.result %[[LJ_NEXT]], %[[J_IVINC]] : index, i32
89 ! CHECK: }
90 end do
91 ! CHECK: fir.store %[[J_RES]]#1 to %[[J_REF]] : !fir.ref<i32>
92 ! CHECK: %[[LI_NEXT:.*]] = arith.addi %[[LI]], %[[ST_I]] : index
93 ! CHECK: %[[I_STEPCAST:.*]] = fir.convert %[[ST_I]] : (index) -> i32
94 ! CHECK: %[[I_IVLOAD:.*]] = fir.load %[[I_REF]] : !fir.ref<i32>
95 ! CHECK: %[[I_IVINC:.*]] = arith.addi %[[I_IVLOAD]], %[[I_STEPCAST]] : i32
96 ! CHECK: fir.result %[[LI_NEXT]], %[[I_IVINC]] : index, i32
97 ! CHECK: }
98 end do
99 ! CHECK: fir.store %[[I_RES]]#1 to %[[I_REF]] : !fir.ref<i32>
100 end subroutine
102 ! Test a downcounting loop
103 ! CHECK-LABEL: down_counting_loop
104 subroutine down_counting_loop()
105 integer :: i
106 ! CHECK: %[[I_REF:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFdown_counting_loopEi"}
108 ! CHECK: %[[C5:.*]] = arith.constant 5 : i32
109 ! CHECK: %[[C5_CVT:.*]] = fir.convert %[[C5]] : (i32) -> index
110 ! CHECK: %[[C1:.*]] = arith.constant 1 : i32
111 ! CHECK: %[[C1_CVT:.*]] = fir.convert %[[C1]] : (i32) -> index
112 ! CHECK: %[[CMINUS1:.*]] = arith.constant -1 : i32
113 ! CHECK: %[[CMINUS1_STEP_CVT:.*]] = fir.convert %[[CMINUS1]] : (i32) -> index
114 ! CHECK: %[[I_LB:.*]] = fir.convert %[[C5_CVT]] : (index) -> i32
115 ! CHECK: %[[I_RES:.*]]:2 = fir.do_loop %[[LI:[^ ]*]] =
116 ! CHECK-SAME: %[[C5_CVT]] to %[[C1_CVT]] step %[[CMINUS1_STEP_CVT]]
117 ! CHECK-SAME: iter_args(%[[I_IV:.*]] = %[[I_LB]]) -> (index, i32) {
118 do i=5,1,-1
119 ! CHECK: fir.store %[[I_IV]] to %[[I_REF]] : !fir.ref<i32>
120 ! CHECK: %[[LI_NEXT:.*]] = arith.addi %[[LI]], %[[CMINUS1_STEP_CVT]] : index
121 ! CHECK: %[[I_STEPCAST:.*]] = fir.convert %[[CMINUS1_STEP_CVT]] : (index) -> i32
122 ! CHECK: %[[I_IVLOAD:.*]] = fir.load %[[I_REF]] : !fir.ref<i32>
123 ! CHECK: %[[I_IVINC:.*]] = arith.addi %[[I_IVLOAD]], %[[I_STEPCAST]] : i32
124 ! CHECK: fir.result %[[LI_NEXT]], %[[I_IVINC]] : index, i32
125 ! CHECK: }
126 end do
127 ! CHECK: fir.store %[[I_RES]]#1 to %[[I_REF]] : !fir.ref<i32>
128 end subroutine
130 ! Test a general loop with a variable step
131 ! CHECK-LABEL: loop_with_variable_step
132 ! CHECK-SAME: (%[[S_REF:.*]]: !fir.ref<i32> {fir.bindc_name = "s"}, %[[E_REF:.*]]: !fir.ref<i32> {fir.bindc_name = "e"}, %[[ST_REF:.*]]: !fir.ref<i32> {fir.bindc_name = "st"}) {
133 subroutine loop_with_variable_step(s,e,st)
134 integer :: s, e, st
135 ! CHECK: %[[S:.*]] = fir.load %[[S_REF]] : !fir.ref<i32>
136 ! CHECK: %[[S_CVT:.*]] = fir.convert %[[S]] : (i32) -> index
137 ! CHECK: %[[E:.*]] = fir.load %[[E_REF]] : !fir.ref<i32>
138 ! CHECK: %[[E_CVT:.*]] = fir.convert %[[E]] : (i32) -> index
139 ! CHECK: %[[ST:.*]] = fir.load %[[ST_REF]] : !fir.ref<i32>
140 ! CHECK: %[[ST_CVT:.*]] = fir.convert %[[ST]] : (i32) -> index
141 ! CHECK: %[[I_LB:.*]] = fir.convert %[[S_CVT]] : (index) -> i32
142 ! CHECK: %[[I_RES:.*]]:2 = fir.do_loop %[[LI:[^ ]*]] =
143 ! CHECK-SAME: %[[S_CVT]] to %[[E_CVT]] step %[[ST_CVT]]
144 ! CHECK-SAME: iter_args(%[[I_IV:.*]] = %[[I_LB]]) -> (index, i32) {
145 do i=s,e,st
146 ! CHECK: fir.store %[[I_IV]] to %[[I_REF]] : !fir.ref<i32>
147 ! CHECK: %[[LI_NEXT:.*]] = arith.addi %[[LI]], %[[ST_CVT]] : index
148 ! CHECK: %[[I_STEPCAST:.*]] = fir.convert %[[ST_CVT]] : (index) -> i32
149 ! CHECK: %[[I_IVLOAD:.*]] = fir.load %[[I_REF]] : !fir.ref<i32>
150 ! CHECK: %[[I_IVINC:.*]] = arith.addi %[[I_IVLOAD]], %[[I_STEPCAST]] : i32
151 ! CHECK: fir.result %[[LI_NEXT]], %[[I_IVINC]] : index, i32
152 ! CHECK: }
153 end do
154 ! CHECK: fir.store %[[I_RES]]#1 to %[[I_REF]] : !fir.ref<i32>
155 end subroutine
157 ! Test usage of pointer variables as index, start, end and step variables
158 ! CHECK-LABEL: loop_with_pointer_variables
159 ! CHECK-SAME: (%[[S_REF:.*]]: !fir.ref<i32> {fir.bindc_name = "s", fir.target}, %[[E_REF:.*]]: !fir.ref<i32> {fir.bindc_name = "e", fir.target}, %[[ST_REF:.*]]: !fir.ref<i32> {fir.bindc_name = "st", fir.target}) {
160 subroutine loop_with_pointer_variables(s,e,st)
161 ! CHECK: %[[E_PTR_REF:.*]] = fir.alloca !fir.ptr<i32> {uniq_name = "_QFloop_with_pointer_variablesEeptr.addr"}
162 ! CHECK: %[[I_REF:.*]] = fir.alloca i32 {bindc_name = "i", fir.target, uniq_name = "_QFloop_with_pointer_variablesEi"}
163 ! CHECK: %[[I_PTR_REF:.*]] = fir.alloca !fir.ptr<i32> {uniq_name = "_QFloop_with_pointer_variablesEiptr.addr"}
164 ! CHECK: %[[S_PTR_REF:.*]] = fir.alloca !fir.ptr<i32> {uniq_name = "_QFloop_with_pointer_variablesEsptr.addr"}
165 ! CHECK: %[[ST_PTR_REF:.*]] = fir.alloca !fir.ptr<i32> {uniq_name = "_QFloop_with_pointer_variablesEstptr.addr"}
166 integer, target :: i
167 integer, target :: s, e, st
168 integer, pointer :: iptr, sptr, eptr, stptr
170 ! CHECK: %[[I_PTR:.*]] = fir.convert %[[I_REF]] : (!fir.ref<i32>) -> !fir.ptr<i32>
171 ! CHECK: fir.store %[[I_PTR]] to %[[I_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
172 ! CHECK: %[[S_PTR:.*]] = fir.convert %[[S_REF]] : (!fir.ref<i32>) -> !fir.ptr<i32>
173 ! CHECK: fir.store %[[S_PTR]] to %[[S_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
174 ! CHECK: %[[E_PTR:.*]] = fir.convert %[[E_REF]] : (!fir.ref<i32>) -> !fir.ptr<i32>
175 ! CHECK: fir.store %[[E_PTR]] to %[[E_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
176 ! CHECK: %[[ST_PTR:.*]] = fir.convert %[[ST_REF]] : (!fir.ref<i32>) -> !fir.ptr<i32>
177 ! CHECK: fir.store %[[ST_PTR]] to %[[ST_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
178 iptr => i
179 sptr => s
180 eptr => e
181 stptr => st
183 ! CHECK: %[[I_PTR:.*]] = fir.load %[[I_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
184 ! CHECK: %[[S_PTR:.*]] = fir.load %[[S_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
185 ! CHECK: %[[S:.*]] = fir.load %[[S_PTR]] : !fir.ptr<i32>
186 ! CHECK: %[[S_CVT:.*]] = fir.convert %[[S]] : (i32) -> index
187 ! CHECK: %[[E_PTR:.*]] = fir.load %[[E_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
188 ! CHECK: %[[E:.*]] = fir.load %[[E_PTR]] : !fir.ptr<i32>
189 ! CHECK: %[[E_CVT:.*]] = fir.convert %[[E]] : (i32) -> index
190 ! CHECK: %[[ST_PTR:.*]] = fir.load %[[ST_PTR_REF]] : !fir.ref<!fir.ptr<i32>>
191 ! CHECK: %[[ST:.*]] = fir.load %[[ST_PTR]] : !fir.ptr<i32>
192 ! CHECK: %[[ST_CVT:.*]] = fir.convert %[[ST]] : (i32) -> index
193 ! CHECK: %[[I_LB:.*]] = fir.convert %[[S_CVT]] : (index) -> i32
194 ! CHECK: %[[I_RES:.*]]:2 = fir.do_loop %[[LI:[^ ]*]] =
195 ! CHECK-SAME: %[[S_CVT]] to %[[E_CVT]] step %[[ST_CVT]]
196 ! CHECK-SAME: iter_args(%[[I_IV:.*]] = %[[I_LB]]) -> (index, i32) {
197 do iptr=sptr,eptr,stptr
198 ! CHECK: fir.store %[[I_IV]] to %[[I_PTR]] : !fir.ptr<i32>
199 ! CHECK: %[[LI_NEXT:.*]] = arith.addi %[[LI]], %[[ST_CVT]] : index
200 ! CHECK: %[[I_STEPCAST:.*]] = fir.convert %[[ST_CVT]] : (index) -> i32
201 ! CHECK: %[[I_IVLOAD:.*]] = fir.load %[[I_PTR]] : !fir.ptr<i32>
202 ! CHECK: %[[I_IVINC:.*]] = arith.addi %[[I_IVLOAD]], %[[I_STEPCAST]] : i32
203 ! CHECK: fir.result %[[LI_NEXT]], %[[I_IVINC]] : index, i32
204 end do
205 ! CHECK: }
206 ! CHECK: fir.store %[[I_RES]]#1 to %[[I_PTR]] : !fir.ptr<i32>
207 end subroutine
209 ! Test usage of non-default integer kind for loop control and loop index variable
210 ! CHECK-LABEL: loop_with_non_default_integer
211 ! CHECK-SAME: (%[[S_REF:.*]]: !fir.ref<i64> {fir.bindc_name = "s"}, %[[E_REF:.*]]: !fir.ref<i64> {fir.bindc_name = "e"}, %[[ST_REF:.*]]: !fir.ref<i64> {fir.bindc_name = "st"}) {
212 subroutine loop_with_non_default_integer(s,e,st)
213 ! CHECK: %[[I_REF:.*]] = fir.alloca i64 {bindc_name = "i", uniq_name = "_QFloop_with_non_default_integerEi"}
214 integer(kind=8):: i
215 ! CHECK: %[[S:.*]] = fir.load %[[S_REF]] : !fir.ref<i64>
216 ! CHECK: %[[S_CVT:.*]] = fir.convert %[[S]] : (i64) -> index
217 ! CHECK: %[[E:.*]] = fir.load %[[E_REF]] : !fir.ref<i64>
218 ! CHECK: %[[E_CVT:.*]] = fir.convert %[[E]] : (i64) -> index
219 ! CHECK: %[[ST:.*]] = fir.load %[[ST_REF]] : !fir.ref<i64>
220 ! CHECK: %[[ST_CVT:.*]] = fir.convert %[[ST]] : (i64) -> index
221 integer(kind=8) :: s, e, st
223 ! CHECK: %[[I_LB:.*]] = fir.convert %[[S_CVT]] : (index) -> i64
224 ! CHECK: %[[I_RES:.*]]:2 = fir.do_loop %[[LI:[^ ]*]] =
225 ! CHECK-SAME: %[[S_CVT]] to %[[E_CVT]] step %[[ST_CVT]]
226 ! CHECK-SAME: iter_args(%[[I_IV:.*]] = %[[I_LB]]) -> (index, i64) {
227 do i=s,e,st
228 ! CHECK: fir.store %[[I_IV]] to %[[I_REF]] : !fir.ref<i64>
229 ! CHECK: %[[LI_NEXT:.*]] = arith.addi %[[LI]], %[[ST_CVT]] : index
230 ! CHECK: %[[I_STEPCAST:.*]] = fir.convert %[[ST_CVT]] : (index) -> i64
231 ! CHECK: %[[I_IVLOAD:.*]] = fir.load %[[I_REF]] : !fir.ref<i64>
232 ! CHECK: %[[I_IVINC:.*]] = arith.addi %[[I_IVLOAD]], %[[I_STEPCAST]] : i64
233 ! CHECK: fir.result %[[LI_NEXT]], %[[I_IVINC]] : index, i64
234 end do
235 ! CHECK: }
236 ! CHECK: fir.store %[[I_RES]]#1 to %[[I_REF]] : !fir.ref<i64>
237 end subroutine
239 ! Test real loop control.
240 ! CHECK-LABEL: loop_with_real_control
241 ! CHECK-SAME: (%[[S_REF:.*]]: !fir.ref<f32> {fir.bindc_name = "s"}, %[[E_REF:.*]]: !fir.ref<f32> {fir.bindc_name = "e"}, %[[ST_REF:.*]]: !fir.ref<f32> {fir.bindc_name = "st"}) {
242 subroutine loop_with_real_control(s,e,st)
243 ! CHECK-DAG: %[[INDEX_REF:.*]] = fir.alloca index
244 ! CHECK-DAG: %[[X_REF:.*]] = fir.alloca f32 {bindc_name = "x", uniq_name = "_QFloop_with_real_controlEx"}
245 ! CHECK-DAG: %[[S:.*]] = fir.load %[[S_REF]] : !fir.ref<f32>
246 ! CHECK-DAG: %[[E:.*]] = fir.load %[[E_REF]] : !fir.ref<f32>
247 ! CHECK-DAG: %[[ST:.*]] = fir.load %[[ST_REF]] : !fir.ref<f32>
248 real :: x, s, e, st
250 ! CHECK: %[[DIFF:.*]] = arith.subf %[[E]], %[[S]] {{.*}}: f32
251 ! CHECK: %[[RANGE:.*]] = arith.addf %[[DIFF]], %[[ST]] {{.*}}: f32
252 ! CHECK: %[[HIGH:.*]] = arith.divf %[[RANGE]], %[[ST]] {{.*}}: f32
253 ! CHECK: %[[HIGH_INDEX:.*]] = fir.convert %[[HIGH]] : (f32) -> index
254 ! CHECK: fir.store %[[HIGH_INDEX]] to %[[INDEX_REF]] : !fir.ref<index>
255 ! CHECK: fir.store %[[S]] to %[[X_REF]] : !fir.ref<f32>
257 ! CHECK: br ^[[HDR:.*]]
258 ! CHECK: ^[[HDR]]: // 2 preds: ^{{.*}}, ^[[EXIT:.*]]
259 ! CHECK-DAG: %[[INDEX:.*]] = fir.load %[[INDEX_REF]] : !fir.ref<index>
260 ! CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
261 ! CHECK: %[[COND:.*]] = arith.cmpi sgt, %[[INDEX]], %[[C0]] : index
262 ! CHECK: cond_br %[[COND]], ^[[BODY:.*]], ^[[EXIT:.*]]
263 do x=s,e,st
264 ! CHECK: ^[[BODY]]: // pred: ^[[HDR]]
265 ! CHECK-DAG: %[[INDEX2:.*]] = fir.load %[[INDEX_REF]] : !fir.ref<index>
266 ! CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
267 ! CHECK: %[[INC:.*]] = arith.subi %[[INDEX2]], %[[C1]] : index
268 ! CHECK: fir.store %[[INC]] to %[[INDEX_REF]] : !fir.ref<index>
269 ! CHECK: %[[X2:.*]] = fir.load %[[X_REF]] : !fir.ref<f32>
270 ! CHECK: %[[XINC:.*]] = arith.addf %[[X2]], %[[ST]] {{.*}}: f32
271 ! CHECK: fir.store %[[XINC]] to %[[X_REF]] : !fir.ref<f32>
272 ! CHECK: br ^[[HDR]]
273 end do
274 end subroutine