1 ! Test lower of elemental user defined assignments
2 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
4 module defined_assignments
8 interface assignment(=)
9 elemental
subroutine assign_t(a
,b
)
11 type(t
),intent(out
) :: a
12 type(t
),intent(in
) :: b
15 interface assignment(=)
16 elemental
subroutine assign_logical_to_real(a
,b
)
17 real, intent(out
) :: a
18 logical, intent(in
) :: b
21 interface assignment(=)
22 elemental
subroutine assign_real_to_logical(a
,b
)
23 logical, intent(out
) :: a
29 ! CHECK-LABEL: func @_QPtest_derived(
30 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>>{{.*}}) {
31 ! CHECK: %[[VAL_1:.*]] = arith.constant 100 : index
32 ! CHECK: %[[VAL_2:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
33 ! CHECK: %[[VAL_3:.*]] = fir.array_load %[[VAL_0]](%[[VAL_2]]) : (!fir.ref<!fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>>, !fir.shape<1>) -> !fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>
34 ! CHECK: %[[VAL_4:.*]] = arith.constant 100 : i64
35 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
36 ! CHECK: %[[VAL_6:.*]] = arith.constant -1 : i64
37 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
38 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : i64
39 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (i64) -> index
40 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
41 ! CHECK: %[[VAL_11:.*]] = fir.slice %[[VAL_5]], %[[VAL_9]], %[[VAL_7]] : (index, index, index) -> !fir.slice<1>
42 ! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_0]](%[[VAL_10]]) {{\[}}%[[VAL_11]]] : (!fir.ref<!fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>
43 ! CHECK: %[[VAL_13:.*]] = arith.constant 1 : index
44 ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
45 ! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_1]], %[[VAL_13]] : index
46 ! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_14]] to %[[VAL_15]] step %[[VAL_13]] unordered iter_args(%[[VAL_18:.*]] = %[[VAL_3]]) -> (!fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>) {
47 ! CHECK: %[[VAL_19:.*]] = fir.array_access %[[VAL_12]], %[[VAL_17]] : (!fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>, index) -> !fir.ref<!fir.type<_QMdefined_assignmentsTt{i:i32}>>
48 ! CHECK: %[[VAL_20:.*]]:2 = fir.array_modify %[[VAL_18]], %[[VAL_17]] : (!fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>, index) -> (!fir.ref<!fir.type<_QMdefined_assignmentsTt{i:i32}>>, !fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>)
49 ! CHECK: fir.call @_QPassign_t(%[[VAL_20]]#0, %[[VAL_19]]) {{.*}}: (!fir.ref<!fir.type<_QMdefined_assignmentsTt{i:i32}>>, !fir.ref<!fir.type<_QMdefined_assignmentsTt{i:i32}>>) -> ()
50 ! CHECK: fir.result %[[VAL_20]]#1 : !fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>
52 ! CHECK: fir.array_merge_store %[[VAL_3]], %[[VAL_21:.*]] to %[[VAL_0]] : !fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>, !fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>, !fir.ref<!fir.array<100x!fir.type<_QMdefined_assignmentsTt{i:i32}>>>
56 ! CHECK-LABEL: func @_QPtest_intrinsic(
57 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}) {
58 ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.logical<4>
59 ! CHECK: %[[VAL_2:.*]] = arith.constant 100 : index
60 ! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
61 ! CHECK: %[[VAL_4:.*]] = fir.array_load %[[VAL_0]](%[[VAL_3]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
62 ! CHECK: %[[VAL_5:.*]] = arith.constant 100 : i64
63 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
64 ! CHECK: %[[VAL_7:.*]] = arith.constant -1 : i64
65 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
66 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : i64
67 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i64) -> index
68 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
69 ! CHECK: %[[VAL_12:.*]] = fir.slice %[[VAL_6]], %[[VAL_10]], %[[VAL_8]] : (index, index, index) -> !fir.slice<1>
70 ! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_0]](%[[VAL_11]]) {{\[}}%[[VAL_12]]] : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<100xf32>
71 ! CHECK: %[[VAL_14:.*]] = arith.constant 0.000000e+00 : f32
72 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
73 ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
74 ! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_2]], %[[VAL_15]] : index
75 ! CHECK: %[[VAL_18:.*]] = fir.do_loop %[[VAL_19:.*]] = %[[VAL_16]] to %[[VAL_17]] step %[[VAL_15]] unordered iter_args(%[[VAL_20:.*]] = %[[VAL_4]]) -> (!fir.array<100xf32>) {
76 ! CHECK: %[[VAL_21:.*]] = fir.array_fetch %[[VAL_13]], %[[VAL_19]] : (!fir.array<100xf32>, index) -> f32
77 ! CHECK: %[[VAL_22:.*]] = arith.cmpf olt, %[[VAL_21]], %[[VAL_14]] : f32
78 ! CHECK: %[[VAL_23:.*]]:2 = fir.array_modify %[[VAL_20]], %[[VAL_19]] : (!fir.array<100xf32>, index) -> (!fir.ref<f32>, !fir.array<100xf32>)
79 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_22]] : (i1) -> !fir.logical<4>
80 ! CHECK: fir.store %[[VAL_24]] to %[[VAL_1]] : !fir.ref<!fir.logical<4>>
81 ! CHECK: fir.call @_QPassign_logical_to_real(%[[VAL_23]]#0, %[[VAL_1]]) {{.*}}: (!fir.ref<f32>, !fir.ref<!fir.logical<4>>) -> ()
82 ! CHECK: fir.result %[[VAL_23]]#1 : !fir.array<100xf32>
84 ! CHECK: fir.array_merge_store %[[VAL_4]], %[[VAL_25:.*]] to %[[VAL_0]] : !fir.array<100xf32>, !fir.array<100xf32>, !fir.ref<!fir.array<100xf32>>
88 ! CHECK-LABEL: func @_QPtest_intrinsic_2(
89 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}) {
90 ! CHECK: %[[VAL_2:.*]] = fir.alloca f32
91 ! CHECK: %[[VAL_3:.*]] = arith.constant 100 : index
92 ! CHECK: %[[VAL_4:.*]] = arith.constant 100 : index
93 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
94 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_0]](%[[VAL_5]]) : (!fir.ref<!fir.array<100x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<100x!fir.logical<4>>
95 ! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
96 ! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_1]](%[[VAL_7]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
97 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
98 ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
99 ! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_3]], %[[VAL_9]] : index
100 ! CHECK: %[[VAL_12:.*]] = fir.do_loop %[[VAL_13:.*]] = %[[VAL_10]] to %[[VAL_11]] step %[[VAL_9]] unordered iter_args(%[[VAL_14:.*]] = %[[VAL_6]]) -> (!fir.array<100x!fir.logical<4>>) {
101 ! CHECK: %[[VAL_15:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_13]] : (!fir.array<100xf32>, index) -> f32
102 ! CHECK: %[[VAL_16:.*]]:2 = fir.array_modify %[[VAL_14]], %[[VAL_13]] : (!fir.array<100x!fir.logical<4>>, index) -> (!fir.ref<!fir.logical<4>>, !fir.array<100x!fir.logical<4>>)
103 ! CHECK: fir.store %[[VAL_15]] to %[[VAL_2]] : !fir.ref<f32>
104 ! CHECK: fir.call @_QPassign_real_to_logical(%[[VAL_16]]#0, %[[VAL_2]]) {{.*}}: (!fir.ref<!fir.logical<4>>, !fir.ref<f32>) -> ()
105 ! CHECK: fir.result %[[VAL_16]]#1 : !fir.array<100x!fir.logical<4>>
107 ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_17:.*]] to %[[VAL_0]] : !fir.array<100x!fir.logical<4>>, !fir.array<100x!fir.logical<4>>, !fir.ref<!fir.array<100x!fir.logical<4>>>
111 ! CHECK-LABEL: func @_QPfrom_char(
112 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>>{{.*}}) {
113 ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
114 ! CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_2]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
115 ! CHECK: %[[VAL_4:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
116 ! CHECK: %[[VAL_5:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.array<?x!fir.char<1,?>>
117 ! CHECK: %[[VAL_6:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
118 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
119 ! CHECK: %[[VAL_8:.*]] = arith.divsi %[[VAL_6]], %[[VAL_7]] : index
120 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
121 ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
122 ! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_9]] : index
123 ! CHECK: %[[VAL_12:.*]] = fir.do_loop %[[VAL_13:.*]] = %[[VAL_10]] to %[[VAL_11]] step %[[VAL_9]] unordered iter_args(%[[VAL_14:.*]] = %[[VAL_4]]) -> (!fir.array<?xi32>) {
124 ! CHECK: %[[VAL_15:.*]] = fir.array_access %[[VAL_5]], %[[VAL_13]] typeparams %[[VAL_8]] : (!fir.array<?x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
125 ! CHECK: %[[VAL_16:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
126 ! CHECK: %[[VAL_17:.*]]:2 = fir.array_modify %[[VAL_14]], %[[VAL_13]] : (!fir.array<?xi32>, index) -> (!fir.ref<i32>, !fir.array<?xi32>)
127 ! CHECK: %[[VAL_18:.*]] = fir.emboxchar %[[VAL_15]], %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
128 ! CHECK: fir.call @_QPsfrom_char(%[[VAL_17]]#0, %[[VAL_18]]) {{.*}}: (!fir.ref<i32>, !fir.boxchar<1>) -> ()
129 ! CHECK: fir.result %[[VAL_17]]#1 : !fir.array<?xi32>
131 ! CHECK: fir.array_merge_store %[[VAL_4]], %[[VAL_19:.*]] to %[[VAL_0]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.box<!fir.array<?xi32>>
135 ! CHECK-LABEL: func @_QPto_char(
136 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>>{{.*}}) {
137 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32
138 ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
139 ! CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_3]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>, index) -> (index, index, index)
140 ! CHECK: %[[VAL_5:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.array<?x!fir.char<1,?>>
141 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
142 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
143 ! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index
144 ! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_4]]#1, %[[VAL_7]] : index
145 ! CHECK: %[[VAL_10:.*]] = fir.do_loop %[[VAL_11:.*]] = %[[VAL_8]] to %[[VAL_9]] step %[[VAL_7]] unordered iter_args(%[[VAL_12:.*]] = %[[VAL_5]]) -> (!fir.array<?x!fir.char<1,?>>) {
146 ! CHECK: %[[VAL_13:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_11]] : (!fir.array<?xi32>, index) -> i32
147 ! CHECK: %[[VAL_14:.*]]:2 = fir.array_modify %[[VAL_12]], %[[VAL_11]] : (!fir.array<?x!fir.char<1,?>>, index) -> (!fir.ref<!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>)
148 ! CHECK: %[[VAL_15:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
149 ! CHECK: %[[VAL_16:.*]] = fir.emboxchar %[[VAL_14]]#0, %[[VAL_15]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
150 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_2]] : !fir.ref<i32>
151 ! CHECK: fir.call @_QPsto_char(%[[VAL_16]], %[[VAL_2]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> ()
152 ! CHECK: fir.result %[[VAL_14]]#1 : !fir.array<?x!fir.char<1,?>>
154 ! CHECK: fir.array_merge_store %[[VAL_5]], %[[VAL_17:.*]] to %[[VAL_1]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.box<!fir.array<?x!fir.char<1,?>>>
158 subroutine test_derived(x
)
159 use defined_assignments
164 subroutine test_intrinsic(x
)
165 use defined_assignments
167 x
= x(100:1:-1) .lt
. 0.
170 subroutine test_intrinsic_2(x
, y
)
171 use defined_assignments
177 subroutine from_char(i
, c
)
178 interface assignment(=)
179 elemental
subroutine sfrom_char(a
,b
)
180 integer, intent(out
) :: a
181 character(*),intent(in
) :: b
189 subroutine to_char(i
, c
)
190 interface assignment(=)
191 elemental
subroutine sto_char(a
,b
)
192 character(*), intent(out
) :: a
193 integer,intent(in
) :: b
201 ! -----------------------------------------------------------------------------
202 ! Test user defined assignments inside FORALL and WHERE
203 ! -----------------------------------------------------------------------------
205 ! CHECK-LABEL: func @_QPtest_in_forall_1(
206 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}) {
207 ! CHECK: %[[VAL_2:.*]] = fir.alloca f32
208 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
209 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
210 ! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index
211 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i32
212 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
213 ! CHECK: %[[VAL_8:.*]] = arith.constant 10 : i32
214 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (i32) -> index
215 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
216 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
217 ! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_0]](%[[VAL_11]]) : (!fir.ref<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<10x!fir.logical<4>>
218 ! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
219 ! CHECK: %[[VAL_14:.*]] = fir.array_load %[[VAL_1]](%[[VAL_13]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
220 ! CHECK: %[[VAL_15:.*]] = fir.do_loop %[[VAL_16:.*]] = %[[VAL_7]] to %[[VAL_9]] step %[[VAL_10]] unordered iter_args(%[[VAL_17:.*]] = %[[VAL_12]]) -> (!fir.array<10x!fir.logical<4>>) {
221 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (index) -> i32
222 ! CHECK: fir.store %[[VAL_18]] to %[[VAL_3]] : !fir.ref<i32>
223 ! CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
224 ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
225 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i32) -> i64
226 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
227 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_22]], %[[VAL_19]] : index
228 ! CHECK: %[[VAL_24:.*]] = fir.array_fetch %[[VAL_14]], %[[VAL_23]] : (!fir.array<10xf32>, index) -> f32
229 ! CHECK: %[[VAL_25:.*]] = arith.constant 1 : index
230 ! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
231 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_26]] : (i32) -> i64
232 ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_27]] : (i64) -> index
233 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_28]], %[[VAL_25]] : index
234 ! CHECK: %[[VAL_30:.*]]:2 = fir.array_modify %[[VAL_17]], %[[VAL_29]] : (!fir.array<10x!fir.logical<4>>, index) -> (!fir.ref<!fir.logical<4>>, !fir.array<10x!fir.logical<4>>)
235 ! CHECK: fir.store %[[VAL_24]] to %[[VAL_2]] : !fir.ref<f32>
236 ! CHECK: fir.call @_QPassign_real_to_logical(%[[VAL_30]]#0, %[[VAL_2]]) {{.*}}: (!fir.ref<!fir.logical<4>>, !fir.ref<f32>) -> ()
237 ! CHECK: fir.result %[[VAL_30]]#1 : !fir.array<10x!fir.logical<4>>
239 ! CHECK: fir.array_merge_store %[[VAL_12]], %[[VAL_31:.*]] to %[[VAL_0]] : !fir.array<10x!fir.logical<4>>, !fir.array<10x!fir.logical<4>>, !fir.ref<!fir.array<10x!fir.logical<4>>>
243 ! CHECK-LABEL: func @_QPtest_in_forall_2(
244 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}) {
245 ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.logical<4>
246 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
247 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
248 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32
249 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> index
250 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : i32
251 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> index
252 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
253 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
254 ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_1]](%[[VAL_10]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
255 ! CHECK: %[[VAL_12:.*]] = fir.do_loop %[[VAL_13:.*]] = %[[VAL_6]] to %[[VAL_8]] step %[[VAL_9]] unordered iter_args(%[[VAL_14:.*]] = %[[VAL_11]]) -> (!fir.array<10xf32>) {
256 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_13]] : (index) -> i32
257 ! CHECK: fir.store %[[VAL_15]] to %[[VAL_3]] : !fir.ref<i32>
258 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
259 ! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
260 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i32) -> i64
261 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
262 ! CHECK: %[[VAL_20:.*]] = arith.subi %[[VAL_19]], %[[VAL_16]] : index
263 ! CHECK-DAG: %[[VAL_21:.*]] = arith.constant 0.000000e+00 : f32
264 ! CHECK-DAG: %[[VAL_22:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_20]] : (!fir.array<10xf32>, index) -> f32
265 ! CHECK: %[[VAL_23:.*]] = arith.cmpf olt, %[[VAL_22]], %[[VAL_21]] : f32
266 ! CHECK: %[[VAL_24:.*]] = arith.constant 1 : index
267 ! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
268 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (i32) -> i64
269 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_26]] : (i64) -> index
270 ! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_27]], %[[VAL_24]] : index
271 ! CHECK: %[[VAL_29:.*]]:2 = fir.array_modify %[[VAL_14]], %[[VAL_28]] : (!fir.array<10xf32>, index) -> (!fir.ref<f32>, !fir.array<10xf32>)
272 ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_23]] : (i1) -> !fir.logical<4>
273 ! CHECK: fir.store %[[VAL_30]] to %[[VAL_2]] : !fir.ref<!fir.logical<4>>
274 ! CHECK: fir.call @_QPassign_logical_to_real(%[[VAL_29]]#0, %[[VAL_2]]) {{.*}}: (!fir.ref<f32>, !fir.ref<!fir.logical<4>>) -> ()
275 ! CHECK: fir.result %[[VAL_29]]#1 : !fir.array<10xf32>
277 ! CHECK: fir.array_merge_store %[[VAL_11]], %[[VAL_31:.*]] to %[[VAL_1]] : !fir.array<10xf32>, !fir.array<10xf32>, !fir.ref<!fir.array<10xf32>>
281 ! CHECK-LABEL: func @_QPtest_intrinsic_where_1(
282 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<!fir.array<10x!fir.logical<4>>>{{.*}}) {
283 ! CHECK: %[[VAL_3:.*]] = fir.alloca f32
284 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
285 ! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index
286 ! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
287 ! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index
288 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
289 ! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_2]](%[[VAL_9]]) : (!fir.ref<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<10x!fir.logical<4>>
290 ! CHECK: %[[VAL_11:.*]] = fir.allocmem !fir.array<10x!fir.logical<4>>
291 ! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
292 ! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_11]](%[[VAL_12]]) : (!fir.heap<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<10x!fir.logical<4>>
293 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
294 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
295 ! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_8]], %[[VAL_14]] : index
296 ! CHECK: %[[VAL_17:.*]] = fir.do_loop %[[VAL_18:.*]] = %[[VAL_15]] to %[[VAL_16]] step %[[VAL_14]] unordered iter_args(%[[VAL_19:.*]] = %[[VAL_13]]) -> (!fir.array<10x!fir.logical<4>>) {
297 ! CHECK: %[[VAL_20:.*]] = fir.array_fetch %[[VAL_10]], %[[VAL_18]] : (!fir.array<10x!fir.logical<4>>, index) -> !fir.logical<4>
298 ! CHECK: %[[VAL_21:.*]] = fir.array_update %[[VAL_19]], %[[VAL_20]], %[[VAL_18]] : (!fir.array<10x!fir.logical<4>>, !fir.logical<4>, index) -> !fir.array<10x!fir.logical<4>>
299 ! CHECK: fir.result %[[VAL_21]] : !fir.array<10x!fir.logical<4>>
301 ! CHECK: fir.array_merge_store %[[VAL_13]], %[[VAL_22:.*]] to %[[VAL_11]] : !fir.array<10x!fir.logical<4>>, !fir.array<10x!fir.logical<4>>, !fir.heap<!fir.array<10x!fir.logical<4>>>
302 ! CHECK: %[[VAL_23:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
303 ! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
304 ! CHECK: %[[VAL_25:.*]] = fir.array_load %[[VAL_0]](%[[VAL_24]]) : (!fir.ref<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<10x!fir.logical<4>>
305 ! CHECK: %[[VAL_26:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
306 ! CHECK: %[[VAL_27:.*]] = fir.array_load %[[VAL_1]](%[[VAL_26]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
307 ! CHECK: %[[VAL_28:.*]] = arith.constant 1 : index
308 ! CHECK: %[[VAL_29:.*]] = arith.constant 0 : index
309 ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_5]], %[[VAL_28]] : index
310 ! CHECK: %[[VAL_31:.*]] = fir.do_loop %[[VAL_32:.*]] = %[[VAL_29]] to %[[VAL_30]] step %[[VAL_28]] unordered iter_args(%[[VAL_33:.*]] = %[[VAL_25]]) -> (!fir.array<10x!fir.logical<4>>) {
311 ! CHECK: %[[VAL_34:.*]] = arith.constant 1 : index
312 ! CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_32]], %[[VAL_34]] : index
313 ! CHECK: %[[VAL_36:.*]] = fir.array_coor %[[VAL_11]](%[[VAL_23]]) %[[VAL_35]] : (!fir.heap<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>, index) -> !fir.ref<!fir.logical<4>>
314 ! CHECK: %[[VAL_37:.*]] = fir.load %[[VAL_36]] : !fir.ref<!fir.logical<4>>
315 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (!fir.logical<4>) -> i1
316 ! CHECK: %[[VAL_39:.*]] = fir.if %[[VAL_38]] -> (!fir.array<10x!fir.logical<4>>) {
317 ! CHECK: %[[VAL_40:.*]] = fir.array_fetch %[[VAL_27]], %[[VAL_32]] : (!fir.array<10xf32>, index) -> f32
318 ! CHECK: %[[VAL_41:.*]]:2 = fir.array_modify %[[VAL_33]], %[[VAL_32]] : (!fir.array<10x!fir.logical<4>>, index) -> (!fir.ref<!fir.logical<4>>, !fir.array<10x!fir.logical<4>>)
319 ! CHECK: fir.store %[[VAL_40]] to %[[VAL_3]] : !fir.ref<f32>
320 ! CHECK: fir.call @_QPassign_real_to_logical(%[[VAL_41]]#0, %[[VAL_3]]) {{.*}}: (!fir.ref<!fir.logical<4>>, !fir.ref<f32>) -> ()
321 ! CHECK: fir.result %[[VAL_41]]#1 : !fir.array<10x!fir.logical<4>>
323 ! CHECK: fir.result %[[VAL_33]] : !fir.array<10x!fir.logical<4>>
325 ! CHECK: fir.result %[[VAL_42:.*]] : !fir.array<10x!fir.logical<4>>
327 ! CHECK: fir.array_merge_store %[[VAL_25]], %[[VAL_43:.*]] to %[[VAL_0]] : !fir.array<10x!fir.logical<4>>, !fir.array<10x!fir.logical<4>>, !fir.ref<!fir.array<10x!fir.logical<4>>>
328 ! CHECK: fir.freemem %[[VAL_11]] : !fir.heap<!fir.array<10x!fir.logical<4>>>
332 ! CHECK-LABEL: func @_QPtest_intrinsic_where_2(
333 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<!fir.array<10x!fir.logical<4>>>{{.*}}) {
334 ! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.logical<4>
335 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
336 ! CHECK: %[[VAL_5:.*]] = arith.constant 10 : index
337 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
338 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
339 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_2]](%[[VAL_8]]) : (!fir.ref<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<10x!fir.logical<4>>
340 ! CHECK: %[[VAL_10:.*]] = fir.allocmem !fir.array<10x!fir.logical<4>>
341 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
342 ! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_10]](%[[VAL_11]]) : (!fir.heap<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<10x!fir.logical<4>>
343 ! CHECK: %[[VAL_13:.*]] = arith.constant 1 : index
344 ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
345 ! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_7]], %[[VAL_13]] : index
346 ! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_14]] to %[[VAL_15]] step %[[VAL_13]] unordered iter_args(%[[VAL_18:.*]] = %[[VAL_12]]) -> (!fir.array<10x!fir.logical<4>>) {
347 ! CHECK: %[[VAL_19:.*]] = fir.array_fetch %[[VAL_9]], %[[VAL_17]] : (!fir.array<10x!fir.logical<4>>, index) -> !fir.logical<4>
348 ! CHECK: %[[VAL_20:.*]] = fir.array_update %[[VAL_18]], %[[VAL_19]], %[[VAL_17]] : (!fir.array<10x!fir.logical<4>>, !fir.logical<4>, index) -> !fir.array<10x!fir.logical<4>>
349 ! CHECK: fir.result %[[VAL_20]] : !fir.array<10x!fir.logical<4>>
351 ! CHECK: fir.array_merge_store %[[VAL_12]], %[[VAL_21:.*]] to %[[VAL_10]] : !fir.array<10x!fir.logical<4>>, !fir.array<10x!fir.logical<4>>, !fir.heap<!fir.array<10x!fir.logical<4>>>
352 ! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
353 ! CHECK: %[[VAL_23:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
354 ! CHECK: %[[VAL_24:.*]] = fir.array_load %[[VAL_1]](%[[VAL_23]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
355 ! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
356 ! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_1]](%[[VAL_25]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
357 ! CHECK: %[[VAL_27:.*]] = arith.constant 0.000000e+00 : f32
358 ! CHECK: %[[VAL_28:.*]] = arith.constant 1 : index
359 ! CHECK: %[[VAL_29:.*]] = arith.constant 0 : index
360 ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_5]], %[[VAL_28]] : index
361 ! CHECK: %[[VAL_31:.*]] = fir.do_loop %[[VAL_32:.*]] = %[[VAL_29]] to %[[VAL_30]] step %[[VAL_28]] unordered iter_args(%[[VAL_33:.*]] = %[[VAL_24]]) -> (!fir.array<10xf32>) {
362 ! CHECK: %[[VAL_34:.*]] = arith.constant 1 : index
363 ! CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_32]], %[[VAL_34]] : index
364 ! CHECK: %[[VAL_36:.*]] = fir.array_coor %[[VAL_10]](%[[VAL_22]]) %[[VAL_35]] : (!fir.heap<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>, index) -> !fir.ref<!fir.logical<4>>
365 ! CHECK: %[[VAL_37:.*]] = fir.load %[[VAL_36]] : !fir.ref<!fir.logical<4>>
366 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (!fir.logical<4>) -> i1
367 ! CHECK: %[[VAL_39:.*]] = fir.if %[[VAL_38]] -> (!fir.array<10xf32>) {
368 ! CHECK: %[[VAL_40:.*]] = fir.array_fetch %[[VAL_26]], %[[VAL_32]] : (!fir.array<10xf32>, index) -> f32
369 ! CHECK: %[[VAL_41:.*]] = arith.cmpf olt, %[[VAL_40]], %[[VAL_27]] : f32
370 ! CHECK: %[[VAL_42:.*]]:2 = fir.array_modify %[[VAL_33]], %[[VAL_32]] : (!fir.array<10xf32>, index) -> (!fir.ref<f32>, !fir.array<10xf32>)
371 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_41]] : (i1) -> !fir.logical<4>
372 ! CHECK: fir.store %[[VAL_43]] to %[[VAL_3]] : !fir.ref<!fir.logical<4>>
373 ! CHECK: fir.call @_QPassign_logical_to_real(%[[VAL_42]]#0, %[[VAL_3]]) {{.*}}: (!fir.ref<f32>, !fir.ref<!fir.logical<4>>) -> ()
374 ! CHECK: fir.result %[[VAL_42]]#1 : !fir.array<10xf32>
376 ! CHECK: fir.result %[[VAL_33]] : !fir.array<10xf32>
378 ! CHECK: fir.result %[[VAL_44:.*]] : !fir.array<10xf32>
380 ! CHECK: fir.array_merge_store %[[VAL_24]], %[[VAL_45:.*]] to %[[VAL_1]] : !fir.array<10xf32>, !fir.array<10xf32>, !fir.ref<!fir.array<10xf32>>
381 ! CHECK: fir.freemem %[[VAL_10]] : !fir.heap<!fir.array<10x!fir.logical<4>>>
385 ! CHECK-LABEL: func @_QPtest_scalar_func_but_not_elemental(
386 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<100xi32>>{{.*}}) {
387 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32
388 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
389 ! CHECK: %[[VAL_4:.*]] = arith.constant 100 : index
390 ! CHECK: %[[VAL_5:.*]] = arith.constant 100 : index
391 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i32
392 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
393 ! CHECK: %[[VAL_8:.*]] = arith.constant 10 : i32
394 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (i32) -> index
395 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
396 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
397 ! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_0]](%[[VAL_11]]) : (!fir.ref<!fir.array<100x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<100x!fir.logical<4>>
398 ! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
399 ! CHECK: %[[VAL_14:.*]] = fir.array_load %[[VAL_1]](%[[VAL_13]]) : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.array<100xi32>
400 ! CHECK: %[[VAL_15:.*]] = fir.do_loop %[[VAL_16:.*]] = %[[VAL_7]] to %[[VAL_9]] step %[[VAL_10]] unordered iter_args(%[[VAL_17:.*]] = %[[VAL_12]]) -> (!fir.array<100x!fir.logical<4>>) {
401 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (index) -> i32
402 ! CHECK: fir.store %[[VAL_18]] to %[[VAL_3]] : !fir.ref<i32>
403 ! CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
404 ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
405 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i32) -> i64
406 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
407 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_22]], %[[VAL_19]] : index
408 ! CHECK: %[[VAL_24:.*]] = fir.array_fetch %[[VAL_14]], %[[VAL_23]] : (!fir.array<100xi32>, index) -> i32
409 ! CHECK: %[[VAL_25:.*]] = arith.constant 1 : index
410 ! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
411 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_26]] : (i32) -> i64
412 ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_27]] : (i64) -> index
413 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_28]], %[[VAL_25]] : index
414 ! CHECK: %[[VAL_30:.*]]:2 = fir.array_modify %[[VAL_17]], %[[VAL_29]] : (!fir.array<100x!fir.logical<4>>, index) -> (!fir.ref<!fir.logical<4>>, !fir.array<100x!fir.logical<4>>)
415 ! CHECK: fir.store %[[VAL_24]] to %[[VAL_2]] : !fir.ref<i32>
416 ! CHECK: fir.call @_QPassign_integer_to_logical(%[[VAL_30]]#0, %[[VAL_2]]) {{.*}}: (!fir.ref<!fir.logical<4>>, !fir.ref<i32>) -> ()
417 ! CHECK: fir.result %[[VAL_30]]#1 : !fir.array<100x!fir.logical<4>>
419 ! CHECK: fir.array_merge_store %[[VAL_12]], %[[VAL_31:.*]] to %[[VAL_0]] : !fir.array<100x!fir.logical<4>>, !fir.array<100x!fir.logical<4>>, !fir.ref<!fir.array<100x!fir.logical<4>>>
423 ! CHECK-LABEL: func @_QPtest_in_forall_with_cleanup(
424 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}) {
425 ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<f32>> {bindc_name = ".result"}
426 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
427 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
428 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32
429 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> index
430 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : i32
431 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i32) -> index
432 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
433 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
434 ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_0]](%[[VAL_10]]) : (!fir.ref<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.array<10x!fir.logical<4>>
435 ! CHECK: %[[VAL_12:.*]] = fir.do_loop %[[VAL_13:.*]] = %[[VAL_6]] to %[[VAL_8]] step %[[VAL_9]] unordered iter_args(%[[VAL_14:.*]] = %[[VAL_11]]) -> (!fir.array<10x!fir.logical<4>>) {
436 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_13]] : (index) -> i32
437 ! CHECK: fir.store %[[VAL_15]] to %[[VAL_3]] : !fir.ref<i32>
438 ! CHECK: %[[VAL_16:.*]] = fir.call @_QPreturns_alloc(%[[VAL_3]]) {{.*}}: (!fir.ref<i32>) -> !fir.box<!fir.heap<f32>>
439 ! CHECK: fir.save_result %[[VAL_16]] to %[[VAL_2]] : !fir.box<!fir.heap<f32>>, !fir.ref<!fir.box<!fir.heap<f32>>>
440 ! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<f32>>>
441 ! CHECK: %[[VAL_18:.*]] = fir.box_addr %[[VAL_17]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>
442 ! CHECK: %[[VAL_19:.*]] = arith.constant 1 : index
443 ! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
444 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i32) -> i64
445 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
446 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_22]], %[[VAL_19]] : index
447 ! CHECK: %[[VAL_24:.*]]:2 = fir.array_modify %[[VAL_14]], %[[VAL_23]] : (!fir.array<10x!fir.logical<4>>, index) -> (!fir.ref<!fir.logical<4>>, !fir.array<10x!fir.logical<4>>)
448 ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<f32>) -> !fir.ref<f32>
449 ! CHECK: fir.call @_QPassign_real_to_logical(%[[VAL_24]]#0, %[[VAL_25]]) {{.*}}: (!fir.ref<!fir.logical<4>>, !fir.ref<f32>) -> ()
450 ! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<f32>>>
451 ! CHECK: %[[VAL_27:.*]] = fir.box_addr %[[VAL_26]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>
452 ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_27]] : (!fir.heap<f32>) -> i64
453 ! CHECK: %[[VAL_29:.*]] = arith.constant 0 : i64
454 ! CHECK: %[[VAL_30:.*]] = arith.cmpi ne, %[[VAL_28]], %[[VAL_29]] : i64
455 ! CHECK: fir.if %[[VAL_30]] {
456 ! CHECK: fir.freemem %[[VAL_27]] : !fir.heap<f32>
458 ! CHECK: fir.result %[[VAL_24]]#1 : !fir.array<10x!fir.logical<4>>
460 ! CHECK: fir.array_merge_store %[[VAL_11]], %[[VAL_31:.*]] to %[[VAL_0]] : !fir.array<10x!fir.logical<4>>, !fir.array<10x!fir.logical<4>>, !fir.ref<!fir.array<10x!fir.logical<4>>>
466 subroutine test_in_forall_1(x
, y
)
467 use defined_assignments
470 forall (i
=1:10) x(i
) = y(i
)
473 subroutine test_in_forall_2(x
, y
)
474 use defined_assignments
477 forall (i
=1:10) y(i
) = y(i
).lt
.0.
480 subroutine test_intrinsic_where_1(x
, y
, l
)
481 use defined_assignments
482 logical :: x(10), l(10)
487 subroutine test_intrinsic_where_2(x
, y
, l
)
488 use defined_assignments
489 logical :: x(10), l(10)
494 subroutine test_scalar_func_but_not_elemental(x
, y
)
495 interface assignment(=)
496 ! scalar, but not elemental
497 elemental
subroutine assign_integer_to_logical(a
,b
)
498 logical, intent(out
) :: a
499 integer, intent(in
) :: b
504 ! Scalar assignment in forall should be treated just like elemental
506 forall(i
=1:10) x(i
) = y(i
)
509 subroutine test_in_forall_with_cleanup(x
, y
)
510 use defined_assignments
512 pure
function returns_alloc(i
)
513 integer, intent(in
) :: i
514 real, allocatable
:: returns_alloc
519 forall (i
=1:10) x(i
) = returns_alloc(i
)
522 ! CHECK-LABEL: func @_QPtest_forall_array(
523 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}) {
524 ! CHECK: %[[VAL_2:.*]] = fir.alloca f32
525 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "i"}
526 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
527 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> index
528 ! CHECK: %[[VAL_6:.*]] = arith.constant 10 : i32
529 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
530 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
531 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !fir.array<?x?x!fir.logical<4>>
532 ! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.array<?x?xf32>
533 ! CHECK: %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_7]] step %[[VAL_8]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_9]]) -> (!fir.array<?x?x!fir.logical<4>>) {
534 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_12]] : (index) -> i32
535 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<i32>
536 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
537 ! CHECK: %[[VAL_16:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_15]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, index) -> (index, index, index)
538 ! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index
539 ! CHECK: %[[VAL_18:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
540 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i32) -> i64
541 ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i64) -> index
542 ! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_20]], %[[VAL_17]] : index
543 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i64
544 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
545 ! CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_17]], %[[VAL_16]]#1 : index
546 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_24]], %[[VAL_17]] : index
547 ! CHECK: %[[VAL_26:.*]] = arith.constant 0 : index
548 ! CHECK: %[[VAL_27:.*]] = arith.subi %[[VAL_25]], %[[VAL_17]] : index
549 ! CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_27]], %[[VAL_23]] : index
550 ! CHECK: %[[VAL_29:.*]] = arith.divsi %[[VAL_28]], %[[VAL_23]] : index
551 ! CHECK: %[[VAL_30:.*]] = arith.cmpi sgt, %[[VAL_29]], %[[VAL_26]] : index
552 ! CHECK: %[[VAL_31:.*]] = arith.select %[[VAL_30]], %[[VAL_29]], %[[VAL_26]] : index
553 ! CHECK: %[[VAL_32:.*]] = arith.constant 1 : index
554 ! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
555 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_33]] : (i32) -> i64
556 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_34]] : (i64) -> index
557 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_35]], %[[VAL_32]] : index
558 ! CHECK: %[[VAL_37:.*]] = arith.constant 1 : i64
559 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (i64) -> index
560 ! CHECK: %[[VAL_39:.*]] = arith.constant 1 : index
561 ! CHECK: %[[VAL_40:.*]] = arith.constant 0 : index
562 ! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_31]], %[[VAL_39]] : index
563 ! CHECK: %[[VAL_42:.*]] = fir.do_loop %[[VAL_43:.*]] = %[[VAL_40]] to %[[VAL_41]] step %[[VAL_39]] unordered iter_args(%[[VAL_44:.*]] = %[[VAL_13]]) -> (!fir.array<?x?x!fir.logical<4>>) {
564 ! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_32]], %[[VAL_32]] : index
565 ! CHECK: %[[VAL_46:.*]] = arith.muli %[[VAL_43]], %[[VAL_38]] : index
566 ! CHECK: %[[VAL_47:.*]] = arith.addi %[[VAL_45]], %[[VAL_46]] : index
567 ! CHECK: %[[VAL_48:.*]] = fir.array_fetch %[[VAL_10]], %[[VAL_36]], %[[VAL_47]] : (!fir.array<?x?xf32>, index, index) -> f32
568 ! CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_17]], %[[VAL_17]] : index
569 ! CHECK: %[[VAL_50:.*]] = arith.muli %[[VAL_43]], %[[VAL_23]] : index
570 ! CHECK: %[[VAL_51:.*]] = arith.addi %[[VAL_49]], %[[VAL_50]] : index
571 ! CHECK: %[[VAL_52:.*]]:2 = fir.array_modify %[[VAL_44]], %[[VAL_21]], %[[VAL_51]] : (!fir.array<?x?x!fir.logical<4>>, index, index) -> (!fir.ref<!fir.logical<4>>, !fir.array<?x?x!fir.logical<4>>)
572 ! CHECK: fir.store %[[VAL_48]] to %[[VAL_2]] : !fir.ref<f32>
573 ! CHECK: fir.call @_QPassign_real_to_logical(%[[VAL_52]]#0, %[[VAL_2]]) {{.*}}: (!fir.ref<!fir.logical<4>>, !fir.ref<f32>) -> ()
574 ! CHECK: fir.result %[[VAL_52]]#1 : !fir.array<?x?x!fir.logical<4>>
576 ! CHECK: fir.result %[[VAL_53:.*]] : !fir.array<?x?x!fir.logical<4>>
578 ! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_54:.*]] to %[[VAL_0]] : !fir.array<?x?x!fir.logical<4>>, !fir.array<?x?x!fir.logical<4>>, !fir.box<!fir.array<?x?x!fir.logical<4>>>
582 subroutine test_forall_array(x
, y
)
583 use defined_assignments
586 forall (i
=1:10) x(i
, :) = y(i
, :)
589 ! CHECK-LABEL: func @_QPfrom_char_forall(
590 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>>{{.*}}) {
591 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
592 ! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i32
593 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (i32) -> index
594 ! CHECK: %[[VAL_5:.*]] = arith.constant 10 : i32
595 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> index
596 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
597 ! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
598 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.array<?x!fir.char<1,?>>
599 ! CHECK: %[[VAL_10:.*]] = fir.do_loop %[[VAL_11:.*]] = %[[VAL_4]] to %[[VAL_6]] step %[[VAL_7]] unordered iter_args(%[[VAL_12:.*]] = %[[VAL_8]]) -> (!fir.array<?xi32>) {
600 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_11]] : (index) -> i32
601 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_2]] : !fir.ref<i32>
602 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
603 ! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
604 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> i64
605 ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
606 ! CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_17]], %[[VAL_14]] : index
607 ! CHECK: %[[VAL_19:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
608 ! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
609 ! CHECK: %[[VAL_21:.*]] = arith.divsi %[[VAL_19]], %[[VAL_20]] : index
610 ! CHECK: %[[VAL_22:.*]] = fir.array_access %[[VAL_9]], %[[VAL_18]] typeparams %[[VAL_21]] : (!fir.array<?x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
611 ! CHECK: %[[VAL_23:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
612 ! CHECK: %[[VAL_24:.*]] = arith.constant 1 : index
613 ! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
614 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (i32) -> i64
615 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_26]] : (i64) -> index
616 ! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_27]], %[[VAL_24]] : index
617 ! CHECK: %[[VAL_29:.*]]:2 = fir.array_modify %[[VAL_12]], %[[VAL_28]] : (!fir.array<?xi32>, index) -> (!fir.ref<i32>, !fir.array<?xi32>)
618 ! CHECK: %[[VAL_30:.*]] = fir.emboxchar %[[VAL_22]], %[[VAL_23]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
619 ! CHECK: fir.call @_QPsfrom_char(%[[VAL_29]]#0, %[[VAL_30]]) {{.*}}: (!fir.ref<i32>, !fir.boxchar<1>) -> ()
620 ! CHECK: fir.result %[[VAL_29]]#1 : !fir.array<?xi32>
622 ! CHECK: fir.array_merge_store %[[VAL_8]], %[[VAL_31:.*]] to %[[VAL_0]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.box<!fir.array<?xi32>>
626 ! CHECK-LABEL: func @_QPto_char_forall(
627 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x!fir.char<1,?>>>{{.*}}) {
628 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32
629 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
630 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
631 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> index
632 ! CHECK: %[[VAL_6:.*]] = arith.constant 10 : i32
633 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
634 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
635 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.array<?x!fir.char<1,?>>
636 ! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
637 ! CHECK: %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_7]] step %[[VAL_8]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_9]]) -> (!fir.array<?x!fir.char<1,?>>) {
638 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_12]] : (index) -> i32
639 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<i32>
640 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
641 ! CHECK: %[[VAL_16:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
642 ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i32) -> i64
643 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i64) -> index
644 ! CHECK: %[[VAL_19:.*]] = arith.subi %[[VAL_18]], %[[VAL_15]] : index
645 ! CHECK: %[[VAL_20:.*]] = fir.array_fetch %[[VAL_10]], %[[VAL_19]] : (!fir.array<?xi32>, index) -> i32
646 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
647 ! CHECK: %[[VAL_22:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
648 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i32) -> i64
649 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (i64) -> index
650 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_24]], %[[VAL_21]] : index
651 ! CHECK: %[[VAL_26:.*]]:2 = fir.array_modify %[[VAL_13]], %[[VAL_25]] : (!fir.array<?x!fir.char<1,?>>, index) -> (!fir.ref<!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>)
652 ! CHECK: %[[VAL_27:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> index
653 ! CHECK: %[[VAL_28:.*]] = fir.emboxchar %[[VAL_26]]#0, %[[VAL_27]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
654 ! CHECK: fir.store %[[VAL_20]] to %[[VAL_2]] : !fir.ref<i32>
655 ! CHECK: fir.call @_QPsto_char(%[[VAL_28]], %[[VAL_2]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> ()
656 ! CHECK: fir.result %[[VAL_26]]#1 : !fir.array<?x!fir.char<1,?>>
658 ! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_29:.*]] to %[[VAL_1]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.box<!fir.array<?x!fir.char<1,?>>>
662 subroutine from_char_forall(i
, c
)
663 interface assignment(=)
664 elemental
subroutine sfrom_char(a
,b
)
665 integer, intent(out
) :: a
666 character(*),intent(in
) :: b
671 forall (j
=1:10) i(j
) = c(j
)
674 subroutine to_char_forall(i
, c
)
675 interface assignment(=)
676 elemental
subroutine sto_char(a
,b
)
677 character(*), intent(out
) :: a
678 integer,intent(in
) :: b
683 forall (j
=1:10) c(j
) = i(j
)
686 ! CHECK-LABEL: func @_QPfrom_char_forall_array(
687 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x?x!fir.char<1,?>>>{{.*}}) {
688 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
689 ! CHECK: %[[VAL_3:.*]] = arith.constant 1 : i32
690 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (i32) -> index
691 ! CHECK: %[[VAL_5:.*]] = arith.constant 10 : i32
692 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> index
693 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
694 ! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.array<?x?xi32>
695 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>) -> !fir.array<?x?x!fir.char<1,?>>
696 ! CHECK: %[[VAL_10:.*]] = fir.do_loop %[[VAL_11:.*]] = %[[VAL_4]] to %[[VAL_6]] step %[[VAL_7]] unordered iter_args(%[[VAL_12:.*]] = %[[VAL_8]]) -> (!fir.array<?x?xi32>) {
697 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_11]] : (index) -> i32
698 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_2]] : !fir.ref<i32>
699 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
700 ! CHECK: %[[VAL_15:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_14]] : (!fir.box<!fir.array<?x?xi32>>, index) -> (index, index, index)
701 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
702 ! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
703 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (i32) -> i64
704 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
705 ! CHECK: %[[VAL_20:.*]] = arith.subi %[[VAL_19]], %[[VAL_16]] : index
706 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : i64
707 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
708 ! CHECK: %[[VAL_23:.*]] = arith.addi %[[VAL_16]], %[[VAL_15]]#1 : index
709 ! CHECK: %[[VAL_24:.*]] = arith.subi %[[VAL_23]], %[[VAL_16]] : index
710 ! CHECK: %[[VAL_25:.*]] = arith.constant 0 : index
711 ! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_24]], %[[VAL_16]] : index
712 ! CHECK: %[[VAL_27:.*]] = arith.addi %[[VAL_26]], %[[VAL_22]] : index
713 ! CHECK: %[[VAL_28:.*]] = arith.divsi %[[VAL_27]], %[[VAL_22]] : index
714 ! CHECK: %[[VAL_29:.*]] = arith.cmpi sgt, %[[VAL_28]], %[[VAL_25]] : index
715 ! CHECK: %[[VAL_30:.*]] = arith.select %[[VAL_29]], %[[VAL_28]], %[[VAL_25]] : index
716 ! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
717 ! CHECK: %[[VAL_32:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
718 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_32]] : (i32) -> i64
719 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_33]] : (i64) -> index
720 ! CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_34]], %[[VAL_31]] : index
721 ! CHECK: %[[VAL_36:.*]] = arith.constant 1 : i64
722 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_36]] : (i64) -> index
723 ! CHECK: %[[VAL_38:.*]] = arith.constant 1 : index
724 ! CHECK: %[[VAL_39:.*]] = arith.constant 0 : index
725 ! CHECK: %[[VAL_40:.*]] = arith.subi %[[VAL_30]], %[[VAL_38]] : index
726 ! CHECK: %[[VAL_41:.*]] = fir.do_loop %[[VAL_42:.*]] = %[[VAL_39]] to %[[VAL_40]] step %[[VAL_38]] unordered iter_args(%[[VAL_43:.*]] = %[[VAL_12]]) -> (!fir.array<?x?xi32>) {
727 ! CHECK: %[[VAL_44:.*]] = arith.subi %[[VAL_31]], %[[VAL_31]] : index
728 ! CHECK: %[[VAL_45:.*]] = arith.muli %[[VAL_42]], %[[VAL_37]] : index
729 ! CHECK: %[[VAL_46:.*]] = arith.addi %[[VAL_44]], %[[VAL_45]] : index
730 ! CHECK: %[[VAL_47:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>) -> index
731 ! CHECK: %[[VAL_48:.*]] = arith.constant 1 : index
732 ! CHECK: %[[VAL_49:.*]] = arith.divsi %[[VAL_47]], %[[VAL_48]] : index
733 ! CHECK: %[[VAL_50:.*]] = fir.array_access %[[VAL_9]], %[[VAL_35]], %[[VAL_46]] typeparams %[[VAL_49]] : (!fir.array<?x?x!fir.char<1,?>>, index, index, index) -> !fir.ref<!fir.char<1,?>>
734 ! CHECK: %[[VAL_51:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>) -> index
735 ! CHECK: %[[VAL_52:.*]] = arith.subi %[[VAL_16]], %[[VAL_16]] : index
736 ! CHECK: %[[VAL_53:.*]] = arith.muli %[[VAL_42]], %[[VAL_22]] : index
737 ! CHECK: %[[VAL_54:.*]] = arith.addi %[[VAL_52]], %[[VAL_53]] : index
738 ! CHECK: %[[VAL_55:.*]]:2 = fir.array_modify %[[VAL_43]], %[[VAL_20]], %[[VAL_54]] : (!fir.array<?x?xi32>, index, index) -> (!fir.ref<i32>, !fir.array<?x?xi32>)
739 ! CHECK: %[[VAL_56:.*]] = fir.emboxchar %[[VAL_50]], %[[VAL_51]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
740 ! CHECK: fir.call @_QPsfrom_char(%[[VAL_55]]#0, %[[VAL_56]]) {{.*}}: (!fir.ref<i32>, !fir.boxchar<1>) -> ()
741 ! CHECK: fir.result %[[VAL_55]]#1 : !fir.array<?x?xi32>
743 ! CHECK: fir.result %[[VAL_57:.*]] : !fir.array<?x?xi32>
745 ! CHECK: fir.array_merge_store %[[VAL_8]], %[[VAL_58:.*]] to %[[VAL_0]] : !fir.array<?x?xi32>, !fir.array<?x?xi32>, !fir.box<!fir.array<?x?xi32>>
749 ! CHECK-LABEL: func @_QPto_char_forall_array(
750 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?x?x!fir.char<1,?>>>{{.*}}) {
751 ! CHECK: %[[VAL_2:.*]] = fir.alloca i32
752 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {adapt.valuebyref, bindc_name = "j"}
753 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
754 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i32) -> index
755 ! CHECK: %[[VAL_6:.*]] = arith.constant 10 : i32
756 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> index
757 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
758 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>) -> !fir.array<?x?x!fir.char<1,?>>
759 ! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.array<?x?xi32>
760 ! CHECK: %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_5]] to %[[VAL_7]] step %[[VAL_8]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_9]]) -> (!fir.array<?x?x!fir.char<1,?>>) {
761 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_12]] : (index) -> i32
762 ! CHECK: fir.store %[[VAL_14]] to %[[VAL_3]] : !fir.ref<i32>
763 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
764 ! CHECK: %[[VAL_16:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_15]] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>, index) -> (index, index, index)
765 ! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index
766 ! CHECK: %[[VAL_18:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
767 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i32) -> i64
768 ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (i64) -> index
769 ! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_20]], %[[VAL_17]] : index
770 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i64
771 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
772 ! CHECK: %[[VAL_24:.*]] = arith.addi %[[VAL_17]], %[[VAL_16]]#1 : index
773 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_24]], %[[VAL_17]] : index
774 ! CHECK: %[[VAL_26:.*]] = arith.constant 0 : index
775 ! CHECK: %[[VAL_27:.*]] = arith.subi %[[VAL_25]], %[[VAL_17]] : index
776 ! CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_27]], %[[VAL_23]] : index
777 ! CHECK: %[[VAL_29:.*]] = arith.divsi %[[VAL_28]], %[[VAL_23]] : index
778 ! CHECK: %[[VAL_30:.*]] = arith.cmpi sgt, %[[VAL_29]], %[[VAL_26]] : index
779 ! CHECK: %[[VAL_31:.*]] = arith.select %[[VAL_30]], %[[VAL_29]], %[[VAL_26]] : index
780 ! CHECK: %[[VAL_32:.*]] = arith.constant 1 : index
781 ! CHECK: %[[VAL_33:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
782 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_33]] : (i32) -> i64
783 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_34]] : (i64) -> index
784 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_35]], %[[VAL_32]] : index
785 ! CHECK: %[[VAL_37:.*]] = arith.constant 1 : i64
786 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (i64) -> index
787 ! CHECK: %[[VAL_39:.*]] = arith.constant 1 : index
788 ! CHECK: %[[VAL_40:.*]] = arith.constant 0 : index
789 ! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_31]], %[[VAL_39]] : index
790 ! CHECK: %[[VAL_42:.*]] = fir.do_loop %[[VAL_43:.*]] = %[[VAL_40]] to %[[VAL_41]] step %[[VAL_39]] unordered iter_args(%[[VAL_44:.*]] = %[[VAL_13]]) -> (!fir.array<?x?x!fir.char<1,?>>) {
791 ! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_32]], %[[VAL_32]] : index
792 ! CHECK: %[[VAL_46:.*]] = arith.muli %[[VAL_43]], %[[VAL_38]] : index
793 ! CHECK: %[[VAL_47:.*]] = arith.addi %[[VAL_45]], %[[VAL_46]] : index
794 ! CHECK: %[[VAL_48:.*]] = fir.array_fetch %[[VAL_10]], %[[VAL_36]], %[[VAL_47]] : (!fir.array<?x?xi32>, index, index) -> i32
795 ! CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_17]], %[[VAL_17]] : index
796 ! CHECK: %[[VAL_50:.*]] = arith.muli %[[VAL_43]], %[[VAL_23]] : index
797 ! CHECK: %[[VAL_51:.*]] = arith.addi %[[VAL_49]], %[[VAL_50]] : index
798 ! CHECK: %[[VAL_52:.*]]:2 = fir.array_modify %[[VAL_44]], %[[VAL_21]], %[[VAL_51]] : (!fir.array<?x?x!fir.char<1,?>>, index, index) -> (!fir.ref<!fir.char<1,?>>, !fir.array<?x?x!fir.char<1,?>>)
799 ! CHECK: %[[VAL_53:.*]] = fir.box_elesize %[[VAL_1]] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>) -> index
800 ! CHECK: %[[VAL_54:.*]] = fir.emboxchar %[[VAL_52]]#0, %[[VAL_53]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
801 ! CHECK: fir.store %[[VAL_48]] to %[[VAL_2]] : !fir.ref<i32>
802 ! CHECK: fir.call @_QPsto_char(%[[VAL_54]], %[[VAL_2]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> ()
803 ! CHECK: fir.result %[[VAL_52]]#1 : !fir.array<?x?x!fir.char<1,?>>
805 ! CHECK: fir.result %[[VAL_55:.*]] : !fir.array<?x?x!fir.char<1,?>>
807 ! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_56:.*]] to %[[VAL_1]] : !fir.array<?x?x!fir.char<1,?>>, !fir.array<?x?x!fir.char<1,?>>, !fir.box<!fir.array<?x?x!fir.char<1,?>>>
811 subroutine from_char_forall_array(i
, c
)
812 interface assignment(=)
813 elemental
subroutine sfrom_char(a
,b
)
814 integer, intent(out
) :: a
815 character(*),intent(in
) :: b
819 character(*) :: c(:, :)
820 forall (j
=1:10) i(j
, :) = c(j
, :)
823 subroutine to_char_forall_array(i
, c
)
824 interface assignment(=)
825 elemental
subroutine sto_char(a
,b
)
826 character(*), intent(out
) :: a
827 integer,intent(in
) :: b
831 character(*) :: c(:, :)
832 forall (j
=1:10) c(j
, :) = i(j
, :)
835 ! TODO: test array user defined assignment inside FORALL.
836 subroutine test_todo(x
, y
)
837 interface assignment(=)
838 ! User assignment is not elemental, it takes array arguments.
839 pure
subroutine assign_array(a
,b
)
840 logical, intent(out
) :: a(:)
841 integer, intent(in
) :: b(:)
846 ! forall(i=1:10) x(i, :) = y(i, :)