1 ! Test allocatable assignments
2 ! RUN: bbc --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s
10 ! -----------------------------------------------------------------------------
11 ! Test simple scalar RHS
12 ! -----------------------------------------------------------------------------
14 ! CHECK-LABEL: func @_QMalloc_assignPtest_simple_scalar(
15 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<f32>>>{{.*}}) {
16 subroutine test_simple_scalar(x
)
17 real, allocatable
:: x
18 ! CHECK: %[[VAL_1:.*]] = arith.constant 4.200000e+01 : f32
19 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<f32>>>
20 ! CHECK: %[[VAL_3:.*]] = fir.box_addr %[[VAL_2]] : (!fir.box<!fir.heap<f32>>) -> !fir.heap<f32>
21 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.heap<f32>) -> i64
22 ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
23 ! CHECK: %[[VAL_6:.*]] = arith.cmpi ne, %[[VAL_4]], %[[VAL_5]] : i64
24 ! CHECK: %[[VAL_7:.*]]:2 = fir.if %[[VAL_6]] -> (i1, !fir.heap<f32>) {
25 ! CHECK: %[[VAL_8:.*]] = arith.constant false
26 ! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_8]] -> (!fir.heap<f32>) {
27 ! CHECK: %[[VAL_10:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
28 ! CHECK: fir.result %[[VAL_10]] : !fir.heap<f32>
30 ! CHECK: fir.result %[[VAL_3]] : !fir.heap<f32>
32 ! CHECK: fir.result %[[VAL_8]], %[[VAL_11:.*]] : i1, !fir.heap<f32>
34 ! CHECK: %[[VAL_12:.*]] = arith.constant true
35 ! CHECK: %[[VAL_13:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
36 ! CHECK: fir.result %[[VAL_12]], %[[VAL_13]] : i1, !fir.heap<f32>
38 ! CHECK: fir.store %[[VAL_1]] to %[[VAL_14:.*]]#1 : !fir.heap<f32>
39 ! CHECK: fir.if %[[VAL_14]]#0 {
40 ! CHECK: fir.if %[[VAL_6]] {
41 ! CHECK: fir.freemem %[[VAL_3]]
43 ! CHECK: %[[VAL_15:.*]] = fir.embox %[[VAL_14]]#1 : (!fir.heap<f32>) -> !fir.box<!fir.heap<f32>>
44 ! CHECK: fir.store %[[VAL_15]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<f32>>>
49 ! CHECK-LABEL: func @_QMalloc_assignPtest_simple_local_scalar() {
50 subroutine test_simple_local_scalar()
51 real, allocatable
:: x
52 ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.heap<f32> {uniq_name = "_QMalloc_assignFtest_simple_local_scalarEx.addr"}
53 ! CHECK: %[[VAL_2:.*]] = fir.zero_bits !fir.heap<f32>
54 ! CHECK: fir.store %[[VAL_2]] to %[[VAL_1]] : !fir.ref<!fir.heap<f32>>
55 ! CHECK: %[[VAL_3:.*]] = arith.constant 4.200000e+01 : f32
56 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.heap<f32>>
57 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.heap<f32>) -> i64
58 ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i64
59 ! CHECK: %[[VAL_7:.*]] = arith.cmpi ne, %[[VAL_5]], %[[VAL_6]] : i64
60 ! CHECK: %[[VAL_8:.*]]:2 = fir.if %[[VAL_7]] -> (i1, !fir.heap<f32>) {
61 ! CHECK: %[[VAL_9:.*]] = arith.constant false
62 ! CHECK: %[[VAL_10:.*]] = fir.if %[[VAL_9]] -> (!fir.heap<f32>) {
63 ! CHECK: %[[VAL_11:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
64 ! CHECK: fir.result %[[VAL_11]] : !fir.heap<f32>
66 ! CHECK: fir.result %[[VAL_4]] : !fir.heap<f32>
68 ! CHECK: fir.result %[[VAL_9]], %[[VAL_12:.*]] : i1, !fir.heap<f32>
70 ! CHECK: %[[VAL_13:.*]] = arith.constant true
71 ! CHECK: %[[VAL_14:.*]] = fir.allocmem f32 {uniq_name = ".auto.alloc"}
72 ! CHECK: fir.result %[[VAL_13]], %[[VAL_14]] : i1, !fir.heap<f32>
74 ! CHECK: fir.store %[[VAL_3]] to %[[VAL_15:.*]]#1 : !fir.heap<f32>
75 ! CHECK: fir.if %[[VAL_15]]#0 {
76 ! CHECK: fir.if %[[VAL_7]] {
77 ! CHECK: fir.freemem %[[VAL_4]]
79 ! CHECK: fir.store %[[VAL_15]]#1 to %[[VAL_1]] : !fir.ref<!fir.heap<f32>>
84 ! -----------------------------------------------------------------------------
85 ! Test character scalar RHS
86 ! -----------------------------------------------------------------------------
88 ! CHECK-LABEL: func @_QMalloc_assignPtest_deferred_char_scalar(
89 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>{{.*}}) {
90 subroutine test_deferred_char_scalar(x
)
91 character(:), allocatable
:: x
92 ! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref<!fir.char<1,12>>
93 ! CHECK: %[[VAL_2:.*]] = arith.constant 12 : index
94 ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
95 ! CHECK: %[[VAL_4:.*]] = fir.box_addr %[[VAL_3]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
96 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (!fir.heap<!fir.char<1,?>>) -> i64
97 ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i64
98 ! CHECK: %[[VAL_7:.*]] = arith.cmpi ne, %[[VAL_5]], %[[VAL_6]] : i64
99 ! CHECK: %[[VAL_8:.*]]:2 = fir.if %[[VAL_7]] -> (i1, !fir.heap<!fir.char<1,?>>) {
100 ! CHECK: %[[VAL_9:.*]] = arith.constant false
101 ! CHECK: %[[VAL_10:.*]] = fir.box_elesize %[[VAL_3]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> index
102 ! CHECK: %[[VAL_11:.*]] = arith.cmpi ne, %[[VAL_10]], %[[VAL_2]] : index
103 ! CHECK: %[[VAL_12:.*]] = arith.select %[[VAL_11]], %[[VAL_11]], %[[VAL_9]] : i1
104 ! CHECK: %[[VAL_13:.*]] = fir.if %[[VAL_12]] -> (!fir.heap<!fir.char<1,?>>) {
105 ! CHECK: %[[VAL_14:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_2]] : index) {uniq_name = ".auto.alloc"}
106 ! CHECK: fir.result %[[VAL_14]] : !fir.heap<!fir.char<1,?>>
108 ! CHECK: fir.result %[[VAL_4]] : !fir.heap<!fir.char<1,?>>
110 ! CHECK: fir.result %[[VAL_12]], %[[VAL_15:.*]] : i1, !fir.heap<!fir.char<1,?>>
112 ! CHECK: %[[VAL_16:.*]] = arith.constant true
113 ! CHECK: %[[VAL_17:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_2]] : index) {uniq_name = ".auto.alloc"}
114 ! CHECK: fir.result %[[VAL_16]], %[[VAL_17]] : i1, !fir.heap<!fir.char<1,?>>
117 ! character assignment ...
118 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_8]]#1 : (!fir.heap<!fir.char<1,?>>) -> !fir.ref<i8>
119 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_24]], %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
120 ! character assignment ...
122 ! CHECK: fir.if %[[VAL_8]]#0 {
123 ! CHECK: fir.if %[[VAL_7]] {
124 ! CHECK: fir.freemem %[[VAL_4]]
126 ! CHECK: %[[VAL_36:.*]] = fir.embox %[[VAL_8]]#1 typeparams %[[VAL_2]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
127 ! CHECK: fir.store %[[VAL_36]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
132 ! CHECK-LABEL: func @_QMalloc_assignPtest_cst_char_scalar(
133 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>{{.*}}) {
134 subroutine test_cst_char_scalar(x
)
135 character(10), allocatable
:: x
136 ! CHECK: %[[VAL_1:.*]] = arith.constant 10 : index
137 ! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref<!fir.char<1,12>>
138 ! CHECK: %[[VAL_3:.*]] = arith.constant 12 : index
139 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
140 ! CHECK: %[[VAL_5:.*]] = fir.box_addr %[[VAL_4]] : (!fir.box<!fir.heap<!fir.char<1,10>>>) -> !fir.heap<!fir.char<1,10>>
141 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.heap<!fir.char<1,10>>) -> i64
142 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : i64
143 ! CHECK: %[[VAL_8:.*]] = arith.cmpi ne, %[[VAL_6]], %[[VAL_7]] : i64
144 ! CHECK: %[[VAL_9:.*]]:2 = fir.if %[[VAL_8]] -> (i1, !fir.heap<!fir.char<1,10>>) {
145 ! CHECK: %[[VAL_10:.*]] = arith.constant false
146 ! CHECK: %[[VAL_11:.*]] = fir.if %[[VAL_10]] -> (!fir.heap<!fir.char<1,10>>) {
147 ! CHECK: %[[VAL_12:.*]] = fir.allocmem !fir.char<1,10> {uniq_name = ".auto.alloc"}
148 ! CHECK: fir.result %[[VAL_12]] : !fir.heap<!fir.char<1,10>>
150 ! CHECK: fir.result %[[VAL_5]] : !fir.heap<!fir.char<1,10>>
152 ! CHECK: fir.result %[[VAL_10]], %[[VAL_13:.*]] : i1, !fir.heap<!fir.char<1,10>>
154 ! CHECK: %[[VAL_14:.*]] = arith.constant true
155 ! CHECK: %[[VAL_15:.*]] = fir.allocmem !fir.char<1,10> {uniq_name = ".auto.alloc"}
156 ! CHECK: fir.result %[[VAL_14]], %[[VAL_15]] : i1, !fir.heap<!fir.char<1,10>>
159 ! character assignment ...
160 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_9]]#1 : (!fir.heap<!fir.char<1,10>>) -> !fir.ref<i8>
161 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_24]], %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
162 ! character assignment ...
164 ! CHECK: fir.if %[[VAL_9]]#0 {
165 ! CHECK: fir.if %[[VAL_8]] {
166 ! CHECK: fir.freemem %[[VAL_5]]
168 ! CHECK: %[[VAL_34:.*]] = fir.embox %[[VAL_9]]#1 : (!fir.heap<!fir.char<1,10>>) -> !fir.box<!fir.heap<!fir.char<1,10>>>
169 ! CHECK: fir.store %[[VAL_34]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,10>>>>
174 ! CHECK-LABEL: func @_QMalloc_assignPtest_dyn_char_scalar(
175 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>{{.*}},
176 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}) {
177 subroutine test_dyn_char_scalar(x
, n
)
179 character(n
), allocatable
:: x
180 ! CHECK: %[[VAL_2A:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
181 ! CHECK: %[[c0_i32:.*]] = arith.constant 0 : i32
182 ! CHECK: %[[VAL_2B:.*]] = arith.cmpi sgt, %[[VAL_2A]], %[[c0_i32]] : i32
183 ! CHECK: %[[VAL_2:.*]] = arith.select %[[VAL_2B]], %[[VAL_2A]], %[[c0_i32]] : i32
184 ! CHECK: %[[VAL_3:.*]] = fir.address_of(@_QQclX48656C6C6F20776F726C6421) : !fir.ref<!fir.char<1,12>>
185 ! CHECK: %[[VAL_4:.*]] = arith.constant 12 : index
186 ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
187 ! CHECK: %[[VAL_6:.*]] = fir.box_addr %[[VAL_5]] : (!fir.box<!fir.heap<!fir.char<1,?>>>) -> !fir.heap<!fir.char<1,?>>
188 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (!fir.heap<!fir.char<1,?>>) -> i64
189 ! CHECK: %[[VAL_8:.*]] = arith.constant 0 : i64
190 ! CHECK: %[[VAL_9:.*]] = arith.cmpi ne, %[[VAL_7]], %[[VAL_8]] : i64
191 ! CHECK: %[[VAL_10:.*]]:2 = fir.if %[[VAL_9]] -> (i1, !fir.heap<!fir.char<1,?>>) {
192 ! CHECK: %[[VAL_11:.*]] = arith.constant false
193 ! CHECK: %[[VAL_12:.*]] = fir.if %[[VAL_11]] -> (!fir.heap<!fir.char<1,?>>) {
194 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_2]] : (i32) -> index
195 ! CHECK: %[[VAL_14:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_13]] : index) {uniq_name = ".auto.alloc"}
196 ! CHECK: fir.result %[[VAL_14]] : !fir.heap<!fir.char<1,?>>
198 ! CHECK: fir.result %[[VAL_6]] : !fir.heap<!fir.char<1,?>>
200 ! CHECK: fir.result %[[VAL_11]], %[[VAL_15:.*]] : i1, !fir.heap<!fir.char<1,?>>
202 ! CHECK: %[[VAL_16:.*]] = arith.constant true
203 ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_2]] : (i32) -> index
204 ! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.char<1,?>(%[[VAL_17]] : index) {uniq_name = ".auto.alloc"}
205 ! CHECK: fir.result %[[VAL_16]], %[[VAL_18]] : i1, !fir.heap<!fir.char<1,?>>
208 ! character assignment ...
209 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_10]]#1 : (!fir.heap<!fir.char<1,?>>) -> !fir.ref<i8>
210 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_24]], %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
211 ! character assignment ...
213 ! CHECK: fir.if %[[VAL_10]]#0 {
214 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_2]] : (i32) -> index
215 ! CHECK: fir.if %[[VAL_9]] {
216 ! CHECK: fir.freemem %[[VAL_6]]
218 ! CHECK: %[[VAL_40:.*]] = fir.embox %[[VAL_10]]#1 typeparams %[[VAL_39]] : (!fir.heap<!fir.char<1,?>>, index) -> !fir.box<!fir.heap<!fir.char<1,?>>>
219 ! CHECK: fir.store %[[VAL_40]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>
224 ! CHECK-LABEL: func @_QMalloc_assignPtest_derived_scalar(
225 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>{{.*}},
226 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>{{.*}}) {
227 subroutine test_derived_scalar(x
, s
)
228 type(t
), allocatable
:: x
231 ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>
232 ! CHECK: %[[VAL_3:.*]] = fir.box_addr %[[VAL_2]] : (!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>) -> !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
233 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) -> i64
234 ! CHECK: %[[VAL_5:.*]] = arith.constant 0 : i64
235 ! CHECK: %[[VAL_6:.*]] = arith.cmpi ne, %[[VAL_4]], %[[VAL_5]] : i64
236 ! CHECK: %[[VAL_7:.*]]:2 = fir.if %[[VAL_6]] -> (i1, !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) {
237 ! CHECK: %[[VAL_8:.*]] = arith.constant false
238 ! CHECK: %[[VAL_9:.*]] = fir.if %[[VAL_8]] -> (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) {
239 ! CHECK: %[[VAL_10:.*]] = fir.allocmem !fir.type<_QMalloc_assignTt{i:i32}> {uniq_name = ".auto.alloc"}
240 ! CHECK: fir.result %[[VAL_10]] : !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
242 ! CHECK: fir.result %[[VAL_3]] : !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
244 ! CHECK: fir.result %[[VAL_8]], %[[VAL_11:.*]] : i1, !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
246 ! CHECK: %[[VAL_12:.*]] = arith.constant true
247 ! CHECK: %[[VAL_13:.*]] = fir.allocmem !fir.type<_QMalloc_assignTt{i:i32}> {uniq_name = ".auto.alloc"}
248 ! CHECK: fir.result %[[VAL_12]], %[[VAL_13]] : i1, !fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>
250 ! CHECK: %[[VAL_14:.*]] = fir.field_index i, !fir.type<_QMalloc_assignTt{i:i32}>
251 ! CHECK: %[[VAL_15:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_14]] : (!fir.ref<!fir.type<_QMalloc_assignTt{i:i32}>>, !fir.field) -> !fir.ref<i32>
252 ! CHECK: %[[VAL_14b:.*]] = fir.field_index i, !fir.type<_QMalloc_assignTt{i:i32}>
253 ! CHECK: %[[VAL_16:.*]] = fir.coordinate_of %[[VAL_7]]#1, %[[VAL_14b]] : (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>, !fir.field) -> !fir.ref<i32>
254 ! CHECK: %[[VAL_17:.*]] = fir.load %[[VAL_15]] : !fir.ref<i32>
255 ! CHECK: fir.store %[[VAL_17]] to %[[VAL_16]] : !fir.ref<i32
256 ! CHECK: fir.if %[[VAL_7]]#0 {
257 ! CHECK: fir.if %[[VAL_6]] {
258 ! CHECK: fir.freemem %[[VAL_3]]
260 ! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_7]]#1 : (!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>) -> !fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>
261 ! CHECK: fir.store %[[VAL_19]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.type<_QMalloc_assignTt{i:i32}>>>>
265 ! -----------------------------------------------------------------------------
266 ! Test numeric/logical array RHS
267 ! -----------------------------------------------------------------------------
269 ! CHECK-LABEL: func @_QMalloc_assignPtest_from_cst_shape_array(
270 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}},
271 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<!fir.array<2x3xf32>>{{.*}}) {
272 subroutine test_from_cst_shape_array(x
, y
)
273 real, allocatable
:: x(:, :)
275 ! CHECK: %[[VAL_2:.*]] = arith.constant 2 : index
276 ! CHECK: %[[VAL_3:.*]] = arith.constant 3 : index
277 ! CHECK: %[[VAL_4:.*]] = arith.constant 2 : index
278 ! CHECK: %[[VAL_5:.*]] = arith.constant 3 : index
279 ! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
280 ! CHECK: %[[VAL_7:.*]] = fir.array_load %[[VAL_1]](%[[VAL_6]]) : (!fir.ref<!fir.array<2x3xf32>>, !fir.shape<2>) -> !fir.array<2x3xf32>
281 ! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
282 ! CHECK: %[[VAL_9:.*]] = fir.box_addr %[[VAL_8]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
283 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
284 ! CHECK: %[[VAL_11:.*]] = arith.constant 0 : i64
285 ! CHECK: %[[VAL_12:.*]] = arith.cmpi ne, %[[VAL_10]], %[[VAL_11]] : i64
286 ! CHECK: %[[VAL_13:.*]]:2 = fir.if %[[VAL_12]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
287 ! CHECK: %[[VAL_14:.*]] = arith.constant false
288 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
289 ! CHECK: %[[VAL_16:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_15]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
290 ! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index
291 ! CHECK: %[[VAL_18:.*]]:3 = fir.box_dims %[[VAL_8]], %[[VAL_17]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
292 ! CHECK: %[[VAL_19:.*]] = arith.cmpi ne, %[[VAL_16]]#1, %[[VAL_4]] : index
293 ! CHECK: %[[VAL_20:.*]] = arith.select %[[VAL_19]], %[[VAL_19]], %[[VAL_14]] : i1
294 ! CHECK: %[[VAL_21:.*]] = arith.cmpi ne, %[[VAL_18]]#1, %[[VAL_5]] : index
295 ! CHECK: %[[VAL_22:.*]] = arith.select %[[VAL_21]], %[[VAL_21]], %[[VAL_20]] : i1
296 ! CHECK: %[[VAL_23:.*]] = fir.if %[[VAL_22]] -> (!fir.heap<!fir.array<?x?xf32>>) {
297 ! CHECK: %[[VAL_24:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_4]], %[[VAL_5]] {uniq_name = ".auto.alloc"}
298 ! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
299 ! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_24]](%[[VAL_25]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
300 ! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
301 ! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
302 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_4]], %[[VAL_27]] : index
303 ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_5]], %[[VAL_27]] : index
304 ! CHECK: %[[VAL_31:.*]] = fir.do_loop %[[VAL_32:.*]] = %[[VAL_28]] to %[[VAL_30]] step %[[VAL_27]] unordered iter_args(%[[VAL_33:.*]] = %[[VAL_26]]) -> (!fir.array<?x?xf32>) {
305 ! CHECK: %[[VAL_34:.*]] = fir.do_loop %[[VAL_35:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_36:.*]] = %[[VAL_33]]) -> (!fir.array<?x?xf32>) {
306 ! CHECK: %[[VAL_37:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_35]], %[[VAL_32]] : (!fir.array<2x3xf32>, index, index) -> f32
307 ! CHECK: %[[VAL_38:.*]] = fir.array_update %[[VAL_36]], %[[VAL_37]], %[[VAL_35]], %[[VAL_32]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
308 ! CHECK: fir.result %[[VAL_38]] : !fir.array<?x?xf32>
310 ! CHECK: fir.result %[[VAL_39:.*]] : !fir.array<?x?xf32>
312 ! CHECK: fir.array_merge_store %[[VAL_26]], %[[VAL_40:.*]] to %[[VAL_24]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
313 ! CHECK: fir.result %[[VAL_24]] : !fir.heap<!fir.array<?x?xf32>>
315 ! CHECK: %[[VAL_41:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
316 ! CHECK: %[[VAL_42:.*]] = fir.array_load %[[VAL_9]](%[[VAL_41]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
317 ! CHECK: %[[VAL_43:.*]] = arith.constant 1 : index
318 ! CHECK: %[[VAL_44:.*]] = arith.constant 0 : index
319 ! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_4]], %[[VAL_43]] : index
320 ! CHECK: %[[VAL_46:.*]] = arith.subi %[[VAL_5]], %[[VAL_43]] : index
321 ! CHECK: %[[VAL_47:.*]] = fir.do_loop %[[VAL_48:.*]] = %[[VAL_44]] to %[[VAL_46]] step %[[VAL_43]] unordered iter_args(%[[VAL_49:.*]] = %[[VAL_42]]) -> (!fir.array<?x?xf32>) {
322 ! CHECK: %[[VAL_50:.*]] = fir.do_loop %[[VAL_51:.*]] = %[[VAL_44]] to %[[VAL_45]] step %[[VAL_43]] unordered iter_args(%[[VAL_52:.*]] = %[[VAL_49]]) -> (!fir.array<?x?xf32>) {
323 ! CHECK: %[[VAL_53:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_51]], %[[VAL_48]] : (!fir.array<2x3xf32>, index, index) -> f32
324 ! CHECK: %[[VAL_54:.*]] = fir.array_update %[[VAL_52]], %[[VAL_53]], %[[VAL_51]], %[[VAL_48]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
325 ! CHECK: fir.result %[[VAL_54]] : !fir.array<?x?xf32>
327 ! CHECK: fir.result %[[VAL_55:.*]] : !fir.array<?x?xf32>
329 ! CHECK: fir.array_merge_store %[[VAL_42]], %[[VAL_56:.*]] to %[[VAL_9]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
330 ! CHECK: fir.result %[[VAL_9]] : !fir.heap<!fir.array<?x?xf32>>
332 ! CHECK: fir.result %[[VAL_22]], %[[VAL_57:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
334 ! CHECK: %[[VAL_58:.*]] = arith.constant true
335 ! CHECK: %[[VAL_59:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_4]], %[[VAL_5]] {uniq_name = ".auto.alloc"}
336 ! CHECK: %[[VAL_60:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
337 ! CHECK: %[[VAL_61:.*]] = fir.array_load %[[VAL_59]](%[[VAL_60]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
338 ! CHECK: %[[VAL_62:.*]] = arith.constant 1 : index
339 ! CHECK: %[[VAL_63:.*]] = arith.constant 0 : index
340 ! CHECK: %[[VAL_64:.*]] = arith.subi %[[VAL_4]], %[[VAL_62]] : index
341 ! CHECK: %[[VAL_65:.*]] = arith.subi %[[VAL_5]], %[[VAL_62]] : index
342 ! CHECK: %[[VAL_66:.*]] = fir.do_loop %[[VAL_67:.*]] = %[[VAL_63]] to %[[VAL_65]] step %[[VAL_62]] unordered iter_args(%[[VAL_68:.*]] = %[[VAL_61]]) -> (!fir.array<?x?xf32>) {
343 ! CHECK: %[[VAL_69:.*]] = fir.do_loop %[[VAL_70:.*]] = %[[VAL_63]] to %[[VAL_64]] step %[[VAL_62]] unordered iter_args(%[[VAL_71:.*]] = %[[VAL_68]]) -> (!fir.array<?x?xf32>) {
344 ! CHECK: %[[VAL_72:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_70]], %[[VAL_67]] : (!fir.array<2x3xf32>, index, index) -> f32
345 ! CHECK: %[[VAL_73:.*]] = fir.array_update %[[VAL_71]], %[[VAL_72]], %[[VAL_70]], %[[VAL_67]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
346 ! CHECK: fir.result %[[VAL_73]] : !fir.array<?x?xf32>
348 ! CHECK: fir.result %[[VAL_74:.*]] : !fir.array<?x?xf32>
350 ! CHECK: fir.array_merge_store %[[VAL_61]], %[[VAL_75:.*]] to %[[VAL_59]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
351 ! CHECK: fir.result %[[VAL_58]], %[[VAL_59]] : i1, !fir.heap<!fir.array<?x?xf32>>
353 ! CHECK: fir.if %[[VAL_76:.*]]#0 {
354 ! CHECK: fir.if %[[VAL_12]] {
355 ! CHECK: fir.freemem %[[VAL_9]] : !fir.heap<!fir.array<?x?xf32>>
357 ! CHECK: %[[VAL_77:.*]] = fir.shape %[[VAL_4]], %[[VAL_5]] : (index, index) -> !fir.shape<2>
358 ! CHECK: %[[VAL_78:.*]] = fir.embox %[[VAL_76]]#1(%[[VAL_77]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
359 ! CHECK: fir.store %[[VAL_78]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
366 ! CHECK-LABEL: func @_QMalloc_assignPtest_from_dyn_shape_array(
367 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}},
368 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}) {
369 subroutine test_from_dyn_shape_array(x
, y
)
370 real, allocatable
:: x(:, :)
373 ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
374 ! CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_2]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
375 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
376 ! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_4]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
377 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.array<?x?xf32>
378 ! CHECK: %[[VAL_7:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
379 ! CHECK: %[[VAL_8:.*]] = fir.box_addr %[[VAL_7]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
380 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
381 ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : i64
382 ! CHECK: %[[VAL_11:.*]] = arith.cmpi ne, %[[VAL_9]], %[[VAL_10]] : i64
383 ! CHECK: %[[VAL_12:.*]]:2 = fir.if %[[VAL_11]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
384 ! CHECK: %[[VAL_13:.*]] = arith.constant false
385 ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
386 ! CHECK: %[[VAL_15:.*]]:3 = fir.box_dims %[[VAL_7]], %[[VAL_14]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
387 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : index
388 ! CHECK: %[[VAL_17:.*]]:3 = fir.box_dims %[[VAL_7]], %[[VAL_16]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
389 ! CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_15]]#1, %[[VAL_3]]#1 : index
390 ! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_18]], %[[VAL_13]] : i1
391 ! CHECK: %[[VAL_20:.*]] = arith.cmpi ne, %[[VAL_17]]#1, %[[VAL_5]]#1 : index
392 ! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_20]], %[[VAL_19]] : i1
393 ! CHECK: %[[VAL_22:.*]] = fir.if %[[VAL_21]] -> (!fir.heap<!fir.array<?x?xf32>>) {
394 ! CHECK: %[[VAL_23:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_3]]#1, %[[VAL_5]]#1 {uniq_name = ".auto.alloc"}
395 ! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
396 ! CHECK: %[[VAL_25:.*]] = fir.array_load %[[VAL_23]](%[[VAL_24]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
397 ! CHECK: %[[VAL_26:.*]] = arith.constant 1 : index
398 ! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
399 ! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_26]] : index
400 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_5]]#1, %[[VAL_26]] : index
401 ! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_27]] to %[[VAL_29]] step %[[VAL_26]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_25]]) -> (!fir.array<?x?xf32>) {
402 ! CHECK: %[[VAL_33:.*]] = fir.do_loop %[[VAL_34:.*]] = %[[VAL_27]] to %[[VAL_28]] step %[[VAL_26]] unordered iter_args(%[[VAL_35:.*]] = %[[VAL_32]]) -> (!fir.array<?x?xf32>) {
403 ! CHECK: %[[VAL_36:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_34]], %[[VAL_31]] : (!fir.array<?x?xf32>, index, index) -> f32
404 ! CHECK: %[[VAL_37:.*]] = fir.array_update %[[VAL_35]], %[[VAL_36]], %[[VAL_34]], %[[VAL_31]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
405 ! CHECK: fir.result %[[VAL_37]] : !fir.array<?x?xf32>
407 ! CHECK: fir.result %[[VAL_38:.*]] : !fir.array<?x?xf32>
409 ! CHECK: fir.array_merge_store %[[VAL_25]], %[[VAL_39:.*]] to %[[VAL_23]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
410 ! CHECK: fir.result %[[VAL_23]] : !fir.heap<!fir.array<?x?xf32>>
412 ! CHECK: %[[VAL_40:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
413 ! CHECK: %[[VAL_41:.*]] = fir.array_load %[[VAL_8]](%[[VAL_40]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
414 ! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
415 ! CHECK: %[[VAL_43:.*]] = arith.constant 0 : index
416 ! CHECK: %[[VAL_44:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_42]] : index
417 ! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_5]]#1, %[[VAL_42]] : index
418 ! CHECK: %[[VAL_46:.*]] = fir.do_loop %[[VAL_47:.*]] = %[[VAL_43]] to %[[VAL_45]] step %[[VAL_42]] unordered iter_args(%[[VAL_48:.*]] = %[[VAL_41]]) -> (!fir.array<?x?xf32>) {
419 ! CHECK: %[[VAL_49:.*]] = fir.do_loop %[[VAL_50:.*]] = %[[VAL_43]] to %[[VAL_44]] step %[[VAL_42]] unordered iter_args(%[[VAL_51:.*]] = %[[VAL_48]]) -> (!fir.array<?x?xf32>) {
420 ! CHECK: %[[VAL_52:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_50]], %[[VAL_47]] : (!fir.array<?x?xf32>, index, index) -> f32
421 ! CHECK: %[[VAL_53:.*]] = fir.array_update %[[VAL_51]], %[[VAL_52]], %[[VAL_50]], %[[VAL_47]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
422 ! CHECK: fir.result %[[VAL_53]] : !fir.array<?x?xf32>
424 ! CHECK: fir.result %[[VAL_54:.*]] : !fir.array<?x?xf32>
426 ! CHECK: fir.array_merge_store %[[VAL_41]], %[[VAL_55:.*]] to %[[VAL_8]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
427 ! CHECK: fir.result %[[VAL_8]] : !fir.heap<!fir.array<?x?xf32>>
429 ! CHECK: fir.result %[[VAL_21]], %[[VAL_56:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
431 ! CHECK: %[[VAL_57:.*]] = arith.constant true
432 ! CHECK: %[[VAL_58:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_3]]#1, %[[VAL_5]]#1 {uniq_name = ".auto.alloc"}
433 ! CHECK: %[[VAL_59:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
434 ! CHECK: %[[VAL_60:.*]] = fir.array_load %[[VAL_58]](%[[VAL_59]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
435 ! CHECK: %[[VAL_61:.*]] = arith.constant 1 : index
436 ! CHECK: %[[VAL_62:.*]] = arith.constant 0 : index
437 ! CHECK: %[[VAL_63:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_61]] : index
438 ! CHECK: %[[VAL_64:.*]] = arith.subi %[[VAL_5]]#1, %[[VAL_61]] : index
439 ! CHECK: %[[VAL_65:.*]] = fir.do_loop %[[VAL_66:.*]] = %[[VAL_62]] to %[[VAL_64]] step %[[VAL_61]] unordered iter_args(%[[VAL_67:.*]] = %[[VAL_60]]) -> (!fir.array<?x?xf32>) {
440 ! CHECK: %[[VAL_68:.*]] = fir.do_loop %[[VAL_69:.*]] = %[[VAL_62]] to %[[VAL_63]] step %[[VAL_61]] unordered iter_args(%[[VAL_70:.*]] = %[[VAL_67]]) -> (!fir.array<?x?xf32>) {
441 ! CHECK: %[[VAL_71:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_69]], %[[VAL_66]] : (!fir.array<?x?xf32>, index, index) -> f32
442 ! CHECK: %[[VAL_72:.*]] = fir.array_update %[[VAL_70]], %[[VAL_71]], %[[VAL_69]], %[[VAL_66]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
443 ! CHECK: fir.result %[[VAL_72]] : !fir.array<?x?xf32>
445 ! CHECK: fir.result %[[VAL_73:.*]] : !fir.array<?x?xf32>
447 ! CHECK: fir.array_merge_store %[[VAL_60]], %[[VAL_74:.*]] to %[[VAL_58]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
448 ! CHECK: fir.result %[[VAL_57]], %[[VAL_58]] : i1, !fir.heap<!fir.array<?x?xf32>>
450 ! CHECK: fir.if %[[VAL_75:.*]]#0 {
451 ! CHECK: fir.if %[[VAL_11]] {
452 ! CHECK: fir.freemem %[[VAL_8]] : !fir.heap<!fir.array<?x?xf32>>
454 ! CHECK: %[[VAL_76:.*]] = fir.shape %[[VAL_3]]#1, %[[VAL_5]]#1 : (index, index) -> !fir.shape<2>
455 ! CHECK: %[[VAL_77:.*]] = fir.embox %[[VAL_75]]#1(%[[VAL_76]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
456 ! CHECK: fir.store %[[VAL_77]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
462 ! CHECK-LABEL: func @_QMalloc_assignPtest_with_lbounds(
463 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}},
464 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}) {
465 subroutine test_with_lbounds(x
, y
)
466 real, allocatable
:: x(:, :)
468 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : i64
469 ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (i64) -> index
470 ! CHECK: %[[VAL_4:.*]] = arith.constant 20 : i64
471 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
472 ! CHECK: %[[VAL_6:.*]] = fir.shift %[[VAL_3]], %[[VAL_5]] : (index, index) -> !fir.shift<2>
473 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : index
474 ! CHECK: %[[VAL_8:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_7]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
475 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
476 ! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_9]] : (!fir.box<!fir.array<?x?xf32>>, index) -> (index, index, index)
477 ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_1]](%[[VAL_6]]) : (!fir.box<!fir.array<?x?xf32>>, !fir.shift<2>) -> !fir.array<?x?xf32>
478 ! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
479 ! CHECK: %[[VAL_13:.*]] = fir.box_addr %[[VAL_12]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
480 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
481 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : i64
482 ! CHECK: %[[VAL_16:.*]] = arith.cmpi ne, %[[VAL_14]], %[[VAL_15]] : i64
483 ! CHECK: %[[VAL_17:.*]]:2 = fir.if %[[VAL_16]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
484 ! CHECK: %[[VAL_18:.*]] = arith.constant false
485 ! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
486 ! CHECK: %[[VAL_20:.*]]:3 = fir.box_dims %[[VAL_12]], %[[VAL_19]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
487 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
488 ! CHECK: %[[VAL_22:.*]]:3 = fir.box_dims %[[VAL_12]], %[[VAL_21]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
489 ! CHECK: %[[VAL_23:.*]] = arith.cmpi ne, %[[VAL_20]]#1, %[[VAL_8]]#1 : index
490 ! CHECK: %[[VAL_24:.*]] = arith.select %[[VAL_23]], %[[VAL_23]], %[[VAL_18]] : i1
491 ! CHECK: %[[VAL_25:.*]] = arith.cmpi ne, %[[VAL_22]]#1, %[[VAL_10]]#1 : index
492 ! CHECK: %[[VAL_26:.*]] = arith.select %[[VAL_25]], %[[VAL_25]], %[[VAL_24]] : i1
493 ! CHECK: %[[VAL_27:.*]] = fir.if %[[VAL_26]] -> (!fir.heap<!fir.array<?x?xf32>>) {
494 ! CHECK: %[[VAL_28:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_8]]#1, %[[VAL_10]]#1 {uniq_name = ".auto.alloc"}
495 ! CHECK: %[[VAL_29:.*]] = fir.shape %[[VAL_8]]#1, %[[VAL_10]]#1 : (index, index) -> !fir.shape<2>
496 ! CHECK: %[[VAL_30:.*]] = fir.array_load %[[VAL_28]](%[[VAL_29]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
497 ! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
498 ! CHECK: %[[VAL_32:.*]] = arith.constant 0 : index
499 ! CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_8]]#1, %[[VAL_31]] : index
500 ! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_31]] : index
501 ! CHECK: %[[VAL_35:.*]] = fir.do_loop %[[VAL_36:.*]] = %[[VAL_32]] to %[[VAL_34]] step %[[VAL_31]] unordered iter_args(%[[VAL_37:.*]] = %[[VAL_30]]) -> (!fir.array<?x?xf32>) {
502 ! CHECK: %[[VAL_38:.*]] = fir.do_loop %[[VAL_39:.*]] = %[[VAL_32]] to %[[VAL_33]] step %[[VAL_31]] unordered iter_args(%[[VAL_40:.*]] = %[[VAL_37]]) -> (!fir.array<?x?xf32>) {
503 ! CHECK: %[[VAL_41:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_39]], %[[VAL_36]] : (!fir.array<?x?xf32>, index, index) -> f32
504 ! CHECK: %[[VAL_42:.*]] = fir.array_update %[[VAL_40]], %[[VAL_41]], %[[VAL_39]], %[[VAL_36]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
505 ! CHECK: fir.result %[[VAL_42]] : !fir.array<?x?xf32>
507 ! CHECK: fir.result %[[VAL_43:.*]] : !fir.array<?x?xf32>
509 ! CHECK: fir.array_merge_store %[[VAL_30]], %[[VAL_44:.*]] to %[[VAL_28]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
510 ! CHECK: fir.result %[[VAL_28]] : !fir.heap<!fir.array<?x?xf32>>
512 ! CHECK: %[[VAL_45:.*]] = fir.shape %[[VAL_8]]#1, %[[VAL_10]]#1 : (index, index) -> !fir.shape<2>
513 ! CHECK: %[[VAL_46:.*]] = fir.array_load %[[VAL_13]](%[[VAL_45]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
514 ! CHECK: %[[VAL_47:.*]] = arith.constant 1 : index
515 ! CHECK: %[[VAL_48:.*]] = arith.constant 0 : index
516 ! CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_8]]#1, %[[VAL_47]] : index
517 ! CHECK: %[[VAL_50:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_47]] : index
518 ! CHECK: %[[VAL_51:.*]] = fir.do_loop %[[VAL_52:.*]] = %[[VAL_48]] to %[[VAL_50]] step %[[VAL_47]] unordered iter_args(%[[VAL_53:.*]] = %[[VAL_46]]) -> (!fir.array<?x?xf32>) {
519 ! CHECK: %[[VAL_54:.*]] = fir.do_loop %[[VAL_55:.*]] = %[[VAL_48]] to %[[VAL_49]] step %[[VAL_47]] unordered iter_args(%[[VAL_56:.*]] = %[[VAL_53]]) -> (!fir.array<?x?xf32>) {
520 ! CHECK: %[[VAL_57:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_55]], %[[VAL_52]] : (!fir.array<?x?xf32>, index, index) -> f32
521 ! CHECK: %[[VAL_58:.*]] = fir.array_update %[[VAL_56]], %[[VAL_57]], %[[VAL_55]], %[[VAL_52]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
522 ! CHECK: fir.result %[[VAL_58]] : !fir.array<?x?xf32>
524 ! CHECK: fir.result %[[VAL_59:.*]] : !fir.array<?x?xf32>
526 ! CHECK: fir.array_merge_store %[[VAL_46]], %[[VAL_60:.*]] to %[[VAL_13]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
527 ! CHECK: fir.result %[[VAL_13]] : !fir.heap<!fir.array<?x?xf32>>
529 ! CHECK: fir.result %[[VAL_26]], %[[VAL_61:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
531 ! CHECK: %[[VAL_62:.*]] = arith.constant true
532 ! CHECK: %[[VAL_63:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_8]]#1, %[[VAL_10]]#1 {uniq_name = ".auto.alloc"}
533 ! CHECK: %[[VAL_64:.*]] = fir.shape %[[VAL_8]]#1, %[[VAL_10]]#1 : (index, index) -> !fir.shape<2>
534 ! CHECK: %[[VAL_65:.*]] = fir.array_load %[[VAL_63]](%[[VAL_64]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
535 ! CHECK: %[[VAL_66:.*]] = arith.constant 1 : index
536 ! CHECK: %[[VAL_67:.*]] = arith.constant 0 : index
537 ! CHECK: %[[VAL_68:.*]] = arith.subi %[[VAL_8]]#1, %[[VAL_66]] : index
538 ! CHECK: %[[VAL_69:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_66]] : index
539 ! CHECK: %[[VAL_70:.*]] = fir.do_loop %[[VAL_71:.*]] = %[[VAL_67]] to %[[VAL_69]] step %[[VAL_66]] unordered iter_args(%[[VAL_72:.*]] = %[[VAL_65]]) -> (!fir.array<?x?xf32>) {
540 ! CHECK: %[[VAL_73:.*]] = fir.do_loop %[[VAL_74:.*]] = %[[VAL_67]] to %[[VAL_68]] step %[[VAL_66]] unordered iter_args(%[[VAL_75:.*]] = %[[VAL_72]]) -> (!fir.array<?x?xf32>) {
541 ! CHECK: %[[VAL_76:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_74]], %[[VAL_71]] : (!fir.array<?x?xf32>, index, index) -> f32
542 ! CHECK: %[[VAL_77:.*]] = fir.array_update %[[VAL_75]], %[[VAL_76]], %[[VAL_74]], %[[VAL_71]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
543 ! CHECK: fir.result %[[VAL_77]] : !fir.array<?x?xf32>
545 ! CHECK: fir.result %[[VAL_78:.*]] : !fir.array<?x?xf32>
547 ! CHECK: fir.array_merge_store %[[VAL_65]], %[[VAL_79:.*]] to %[[VAL_63]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
548 ! CHECK: fir.result %[[VAL_62]], %[[VAL_63]] : i1, !fir.heap<!fir.array<?x?xf32>>
550 ! CHECK: fir.if %[[VAL_80:.*]]#0 {
551 ! CHECK: fir.if %[[VAL_16]] {
552 ! CHECK: fir.freemem %[[VAL_13]] : !fir.heap<!fir.array<?x?xf32>>
554 ! CHECK: %[[VAL_81:.*]] = fir.shape_shift %[[VAL_3]], %[[VAL_8]]#1, %[[VAL_5]], %[[VAL_10]]#1 : (index, index, index, index) -> !fir.shapeshift<2>
555 ! CHECK: %[[VAL_82:.*]] = fir.embox %[[VAL_80]]#1(%[[VAL_81]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
556 ! CHECK: fir.store %[[VAL_82]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
563 ! CHECK-LABEL: func @_QMalloc_assignPtest_runtime_shape(
564 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>{{.*}}) {
565 subroutine test_runtime_shape(x
)
566 real, allocatable
:: x(:, :)
568 function return_pointer()
569 real, pointer :: return_pointer(:, :)
572 ! CHECK: %[[VAL_1:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?x?xf32>>> {bindc_name = ".result"}
573 ! CHECK: %[[VAL_2:.*]] = fir.call @_QPreturn_pointer() {{.*}}: () -> !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
574 ! CHECK: fir.save_result %[[VAL_2]] to %[[VAL_1]] : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
575 ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
576 ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
577 ! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_4]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
578 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
579 ! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_6]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
580 ! CHECK: %[[VAL_8:.*]] = fir.shift %[[VAL_5]]#0, %[[VAL_7]]#0 : (index, index) -> !fir.shift<2>
581 ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
582 ! CHECK: %[[VAL_10:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_9]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
583 ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
584 ! CHECK: %[[VAL_12:.*]]:3 = fir.box_dims %[[VAL_3]], %[[VAL_11]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, index) -> (index, index, index)
585 ! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>, !fir.shift<2>) -> !fir.array<?x?xf32>
586 ! CHECK: %[[VAL_14:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
587 ! CHECK: %[[VAL_15:.*]] = fir.box_addr %[[VAL_14]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
588 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (!fir.heap<!fir.array<?x?xf32>>) -> i64
589 ! CHECK: %[[VAL_17:.*]] = arith.constant 0 : i64
590 ! CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_16]], %[[VAL_17]] : i64
591 ! CHECK: %[[VAL_19:.*]]:2 = fir.if %[[VAL_18]] -> (i1, !fir.heap<!fir.array<?x?xf32>>) {
592 ! CHECK: %[[VAL_20:.*]] = arith.constant false
593 ! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
594 ! CHECK: %[[VAL_22:.*]]:3 = fir.box_dims %[[VAL_14]], %[[VAL_21]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
595 ! CHECK: %[[VAL_23:.*]] = arith.constant 1 : index
596 ! CHECK: %[[VAL_24:.*]]:3 = fir.box_dims %[[VAL_14]], %[[VAL_23]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>, index) -> (index, index, index)
597 ! CHECK: %[[VAL_25:.*]] = arith.cmpi ne, %[[VAL_22]]#1, %[[VAL_10]]#1 : index
598 ! CHECK: %[[VAL_26:.*]] = arith.select %[[VAL_25]], %[[VAL_25]], %[[VAL_20]] : i1
599 ! CHECK: %[[VAL_27:.*]] = arith.cmpi ne, %[[VAL_24]]#1, %[[VAL_12]]#1 : index
600 ! CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_27]], %[[VAL_26]] : i1
601 ! CHECK: %[[VAL_29:.*]] = fir.if %[[VAL_28]] -> (!fir.heap<!fir.array<?x?xf32>>) {
602 ! CHECK: %[[VAL_30:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_10]]#1, %[[VAL_12]]#1 {uniq_name = ".auto.alloc"}
603 ! CHECK: %[[VAL_31:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
604 ! CHECK: %[[VAL_32:.*]] = fir.array_load %[[VAL_30]](%[[VAL_31]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
605 ! CHECK: %[[VAL_33:.*]] = arith.constant 1 : index
606 ! CHECK: %[[VAL_34:.*]] = arith.constant 0 : index
607 ! CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_33]] : index
608 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_12]]#1, %[[VAL_33]] : index
609 ! CHECK: %[[VAL_37:.*]] = fir.do_loop %[[VAL_38:.*]] = %[[VAL_34]] to %[[VAL_36]] step %[[VAL_33]] unordered iter_args(%[[VAL_39:.*]] = %[[VAL_32]]) -> (!fir.array<?x?xf32>) {
610 ! CHECK: %[[VAL_40:.*]] = fir.do_loop %[[VAL_41:.*]] = %[[VAL_34]] to %[[VAL_35]] step %[[VAL_33]] unordered iter_args(%[[VAL_42:.*]] = %[[VAL_39]]) -> (!fir.array<?x?xf32>) {
611 ! CHECK: %[[VAL_43:.*]] = fir.array_fetch %[[VAL_13]], %[[VAL_41]], %[[VAL_38]] : (!fir.array<?x?xf32>, index, index) -> f32
612 ! CHECK: %[[VAL_44:.*]] = fir.array_update %[[VAL_42]], %[[VAL_43]], %[[VAL_41]], %[[VAL_38]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
613 ! CHECK: fir.result %[[VAL_44]] : !fir.array<?x?xf32>
615 ! CHECK: fir.result %[[VAL_45:.*]] : !fir.array<?x?xf32>
617 ! CHECK: fir.array_merge_store %[[VAL_32]], %[[VAL_46:.*]] to %[[VAL_30]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
618 ! CHECK: fir.result %[[VAL_30]] : !fir.heap<!fir.array<?x?xf32>>
620 ! CHECK: %[[VAL_47:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
621 ! CHECK: %[[VAL_48:.*]] = fir.array_load %[[VAL_15]](%[[VAL_47]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
622 ! CHECK: %[[VAL_49:.*]] = arith.constant 1 : index
623 ! CHECK: %[[VAL_50:.*]] = arith.constant 0 : index
624 ! CHECK: %[[VAL_51:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_49]] : index
625 ! CHECK: %[[VAL_52:.*]] = arith.subi %[[VAL_12]]#1, %[[VAL_49]] : index
626 ! CHECK: %[[VAL_53:.*]] = fir.do_loop %[[VAL_54:.*]] = %[[VAL_50]] to %[[VAL_52]] step %[[VAL_49]] unordered iter_args(%[[VAL_55:.*]] = %[[VAL_48]]) -> (!fir.array<?x?xf32>) {
627 ! CHECK: %[[VAL_56:.*]] = fir.do_loop %[[VAL_57:.*]] = %[[VAL_50]] to %[[VAL_51]] step %[[VAL_49]] unordered iter_args(%[[VAL_58:.*]] = %[[VAL_55]]) -> (!fir.array<?x?xf32>) {
628 ! CHECK: %[[VAL_59:.*]] = fir.array_fetch %[[VAL_13]], %[[VAL_57]], %[[VAL_54]] : (!fir.array<?x?xf32>, index, index) -> f32
629 ! CHECK: %[[VAL_60:.*]] = fir.array_update %[[VAL_58]], %[[VAL_59]], %[[VAL_57]], %[[VAL_54]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
630 ! CHECK: fir.result %[[VAL_60]] : !fir.array<?x?xf32>
632 ! CHECK: fir.result %[[VAL_61:.*]] : !fir.array<?x?xf32>
634 ! CHECK: fir.array_merge_store %[[VAL_48]], %[[VAL_62:.*]] to %[[VAL_15]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
635 ! CHECK: fir.result %[[VAL_15]] : !fir.heap<!fir.array<?x?xf32>>
637 ! CHECK: fir.result %[[VAL_28]], %[[VAL_63:.*]] : i1, !fir.heap<!fir.array<?x?xf32>>
639 ! CHECK: %[[VAL_64:.*]] = arith.constant true
640 ! CHECK: %[[VAL_65:.*]] = fir.allocmem !fir.array<?x?xf32>, %[[VAL_10]]#1, %[[VAL_12]]#1 {uniq_name = ".auto.alloc"}
641 ! CHECK: %[[VAL_66:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
642 ! CHECK: %[[VAL_67:.*]] = fir.array_load %[[VAL_65]](%[[VAL_66]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>
643 ! CHECK: %[[VAL_68:.*]] = arith.constant 1 : index
644 ! CHECK: %[[VAL_69:.*]] = arith.constant 0 : index
645 ! CHECK: %[[VAL_70:.*]] = arith.subi %[[VAL_10]]#1, %[[VAL_68]] : index
646 ! CHECK: %[[VAL_71:.*]] = arith.subi %[[VAL_12]]#1, %[[VAL_68]] : index
647 ! CHECK: %[[VAL_72:.*]] = fir.do_loop %[[VAL_73:.*]] = %[[VAL_69]] to %[[VAL_71]] step %[[VAL_68]] unordered iter_args(%[[VAL_74:.*]] = %[[VAL_67]]) -> (!fir.array<?x?xf32>) {
648 ! CHECK: %[[VAL_75:.*]] = fir.do_loop %[[VAL_76:.*]] = %[[VAL_69]] to %[[VAL_70]] step %[[VAL_68]] unordered iter_args(%[[VAL_77:.*]] = %[[VAL_74]]) -> (!fir.array<?x?xf32>) {
649 ! CHECK: %[[VAL_78:.*]] = fir.array_fetch %[[VAL_13]], %[[VAL_76]], %[[VAL_73]] : (!fir.array<?x?xf32>, index, index) -> f32
650 ! CHECK: %[[VAL_79:.*]] = fir.array_update %[[VAL_77]], %[[VAL_78]], %[[VAL_76]], %[[VAL_73]] : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>
651 ! CHECK: fir.result %[[VAL_79]] : !fir.array<?x?xf32>
653 ! CHECK: fir.result %[[VAL_80:.*]] : !fir.array<?x?xf32>
655 ! CHECK: fir.array_merge_store %[[VAL_67]], %[[VAL_81:.*]] to %[[VAL_65]] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.heap<!fir.array<?x?xf32>>
656 ! CHECK: fir.result %[[VAL_64]], %[[VAL_65]] : i1, !fir.heap<!fir.array<?x?xf32>>
658 ! CHECK: fir.if %[[VAL_82:.*]]#0 {
659 ! CHECK: fir.if %[[VAL_18]] {
660 ! CHECK: fir.freemem %[[VAL_15]] : !fir.heap<!fir.array<?x?xf32>>
662 ! CHECK: %[[VAL_83:.*]] = fir.shape %[[VAL_10]]#1, %[[VAL_12]]#1 : (index, index) -> !fir.shape<2>
663 ! CHECK: %[[VAL_84:.*]] = fir.embox %[[VAL_82]]#1(%[[VAL_83]]) : (!fir.heap<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.box<!fir.heap<!fir.array<?x?xf32>>>
664 ! CHECK: fir.store %[[VAL_84]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
671 ! CHECK-LABEL: func @_QMalloc_assignPtest_scalar_rhs(
672 subroutine test_scalar_rhs(x
, y
)
673 real, allocatable
:: x(:)
675 ! CHECK: fir.if %{{.*}} -> {{.*}} {
676 ! CHECK: fir.if %false -> {{.*}} {
679 ! CHECK: %[[error_msg_addr:.*]] = fir.address_of(@[[error_message:.*]]) : !fir.ref<!fir.char<1,76>>
680 ! CHECK: %[[msg_addr_cast:.*]] = fir.convert %[[error_msg_addr]] : (!fir.ref<!fir.char<1,76>>) -> !fir.ref<i8>
681 ! CHECK: %{{.*}} = fir.call @_FortranAReportFatalUserError(%[[msg_addr_cast]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i32) -> none
682 ! CHECK-NOT: allocmem
687 ! -----------------------------------------------------------------------------
688 ! Test character array RHS
689 ! -----------------------------------------------------------------------------
692 ! Hit TODO: gathering lhs length in array expression
693 !subroutine test_deferred_char_rhs_scalar(x)
694 ! character(:), allocatable :: x(:)
698 ! CHECK: func @_QMalloc_assignPtest_cst_char_rhs_scalar(
699 subroutine test_cst_char_rhs_scalar(x
)
700 character(10), allocatable
:: x(:)
702 ! CHECK: fir.if %{{.*}} -> {{.*}} {
703 ! CHECK: fir.if %false -> {{.*}} {
706 ! TODO: runtime error if unallocated
707 ! CHECK-NOT: allocmem
711 ! CHECK: func @_QMalloc_assignPtest_dyn_char_rhs_scalar(
712 subroutine test_dyn_char_rhs_scalar(x
, n
)
714 character(n
), allocatable
:: x(:)
716 ! CHECK: fir.if %{{.*}} -> {{.*}} {
717 ! CHECK: fir.if %false -> {{.*}} {
720 ! TODO: runtime error if unallocated
721 ! CHECK-NOT: allocmem
725 ! Hit TODO: gathering lhs length in array expression
726 !subroutine test_deferred_char(x, c)
727 ! character(:), allocatable :: x(:)
728 ! character(12) :: c(20)
732 ! CHECK-LABEL: func @_QMalloc_assignPtest_cst_char(
733 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>{{.*}},
734 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
735 subroutine test_cst_char(x
, c
)
736 character(10), allocatable
:: x(:)
737 character(12) :: c(20)
738 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
739 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<20x!fir.char<1,12>>>
740 ! CHECK: %[[VAL_3:.*]] = arith.constant 12 : index
741 ! CHECK: %[[VAL_5:.*]] = arith.constant 20 : index
742 ! CHECK: %[[VAL_6:.*]] = arith.constant 20 : index
743 ! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
744 ! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_4]](%[[VAL_7]]) : (!fir.ref<!fir.array<20x!fir.char<1,12>>>, !fir.shape<1>) -> !fir.array<20x!fir.char<1,12>>
745 ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
746 ! CHECK: %[[VAL_10:.*]] = fir.box_addr %[[VAL_9]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,10>>>
747 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.heap<!fir.array<?x!fir.char<1,10>>>) -> i64
748 ! CHECK: %[[VAL_12:.*]] = arith.constant 0 : i64
749 ! CHECK: %[[VAL_13:.*]] = arith.cmpi ne, %[[VAL_11]], %[[VAL_12]] : i64
750 ! CHECK: %[[VAL_14:.*]]:2 = fir.if %[[VAL_13]] -> (i1, !fir.heap<!fir.array<?x!fir.char<1,10>>>) {
751 ! CHECK: %[[VAL_15:.*]] = arith.constant false
752 ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
753 ! CHECK: %[[VAL_17:.*]]:3 = fir.box_dims %[[VAL_9]], %[[VAL_16]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>, index) -> (index, index, index)
754 ! CHECK: %[[VAL_18:.*]] = arith.cmpi ne, %[[VAL_17]]#1, %[[VAL_6]] : index
755 ! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_18]], %[[VAL_15]] : i1
756 ! CHECK: %[[VAL_20:.*]] = fir.if %[[VAL_19]] -> (!fir.heap<!fir.array<?x!fir.char<1,10>>>) {
757 ! CHECK: %[[VAL_21:.*]] = fir.allocmem !fir.array<?x!fir.char<1,10>>, %[[VAL_6]] {uniq_name = ".auto.alloc"}
758 ! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
759 ! CHECK: %[[VAL_23:.*]] = fir.array_load %[[VAL_21]](%[[VAL_22]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
760 ! CHECK: %[[VAL_24:.*]] = arith.constant 1 : index
761 ! CHECK: %[[VAL_25:.*]] = arith.constant 0 : index
762 ! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_6]], %[[VAL_24]] : index
763 ! CHECK: %[[VAL_27:.*]] = fir.do_loop %[[VAL_28:.*]] = %[[VAL_25]] to %[[VAL_26]] step %[[VAL_24]] unordered iter_args(%[[VAL_29:.*]] = %[[VAL_23]]) -> (!fir.array<?x!fir.char<1,10>>) {
764 ! CHECK: %[[VAL_30:.*]] = fir.array_access %[[VAL_8]], %[[VAL_28]] : (!fir.array<20x!fir.char<1,12>>, index) -> !fir.ref<!fir.char<1,12>>
765 ! CHECK: %[[VAL_31:.*]] = fir.array_access %[[VAL_29]], %[[VAL_28]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
766 ! CHECK: %[[VAL_32:.*]] = arith.constant 10 : index
767 ! CHECK: %[[VAL_33:.*]] = arith.cmpi slt, %[[VAL_32]], %[[VAL_3]] : index
768 ! CHECK: %[[VAL_34:.*]] = arith.select %[[VAL_33]], %[[VAL_32]], %[[VAL_3]] : index
769 ! CHECK: %[[VAL_35:.*]] = arith.constant 1 : i64
770 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_34]] : (index) -> i64
771 ! CHECK: %[[VAL_37:.*]] = arith.muli %[[VAL_35]], %[[VAL_36]] : i64
772 ! CHECK: %[[VAL_38:.*]] = arith.constant false
773 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
774 ! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_30]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
775 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_39]], %[[VAL_40]], %[[VAL_37]], %[[VAL_38]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
776 ! CHECK: %[[VAL_41:.*]] = arith.constant 1 : index
777 ! CHECK: %[[VAL_42:.*]] = arith.subi %[[VAL_32]], %[[VAL_41]] : index
778 ! CHECK: %[[VAL_43:.*]] = arith.constant 32 : i8
779 ! CHECK: %[[VAL_44:.*]] = fir.undefined !fir.char<1>
780 ! CHECK: %[[VAL_45:.*]] = fir.insert_value %[[VAL_44]], %[[VAL_43]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
781 ! CHECK: %[[VAL_46:.*]] = arith.constant 1 : index
782 ! CHECK: fir.do_loop %[[VAL_47:.*]] = %[[VAL_34]] to %[[VAL_42]] step %[[VAL_46]] {
783 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
784 ! CHECK: %[[VAL_49:.*]] = fir.coordinate_of %[[VAL_48]], %[[VAL_47]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
785 ! CHECK: fir.store %[[VAL_45]] to %[[VAL_49]] : !fir.ref<!fir.char<1>>
787 ! CHECK: %[[VAL_50:.*]] = fir.array_amend %[[VAL_29]], %[[VAL_31]] : (!fir.array<?x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<?x!fir.char<1,10>>
788 ! CHECK: fir.result %[[VAL_50]] : !fir.array<?x!fir.char<1,10>>
790 ! CHECK: fir.array_merge_store %[[VAL_23]], %[[VAL_51:.*]] to %[[VAL_21]] : !fir.array<?x!fir.char<1,10>>, !fir.array<?x!fir.char<1,10>>, !fir.heap<!fir.array<?x!fir.char<1,10>>>
791 ! CHECK: fir.result %[[VAL_21]] : !fir.heap<!fir.array<?x!fir.char<1,10>>>
793 ! CHECK: %[[VAL_52:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
794 ! CHECK: %[[VAL_53:.*]] = fir.array_load %[[VAL_10]](%[[VAL_52]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
795 ! CHECK: %[[VAL_54:.*]] = arith.constant 1 : index
796 ! CHECK: %[[VAL_55:.*]] = arith.constant 0 : index
797 ! CHECK: %[[VAL_56:.*]] = arith.subi %[[VAL_6]], %[[VAL_54]] : index
798 ! CHECK: %[[VAL_57:.*]] = fir.do_loop %[[VAL_58:.*]] = %[[VAL_55]] to %[[VAL_56]] step %[[VAL_54]] unordered iter_args(%[[VAL_59:.*]] = %[[VAL_53]]) -> (!fir.array<?x!fir.char<1,10>>) {
799 ! CHECK: %[[VAL_60:.*]] = fir.array_access %[[VAL_8]], %[[VAL_58]] : (!fir.array<20x!fir.char<1,12>>, index) -> !fir.ref<!fir.char<1,12>>
800 ! CHECK: %[[VAL_61:.*]] = fir.array_access %[[VAL_59]], %[[VAL_58]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
801 ! CHECK: %[[VAL_62:.*]] = arith.constant 10 : index
802 ! CHECK: %[[VAL_63:.*]] = arith.cmpi slt, %[[VAL_62]], %[[VAL_3]] : index
803 ! CHECK: %[[VAL_64:.*]] = arith.select %[[VAL_63]], %[[VAL_62]], %[[VAL_3]] : index
804 ! CHECK: %[[VAL_65:.*]] = arith.constant 1 : i64
805 ! CHECK: %[[VAL_66:.*]] = fir.convert %[[VAL_64]] : (index) -> i64
806 ! CHECK: %[[VAL_67:.*]] = arith.muli %[[VAL_65]], %[[VAL_66]] : i64
807 ! CHECK: %[[VAL_68:.*]] = arith.constant false
808 ! CHECK: %[[VAL_69:.*]] = fir.convert %[[VAL_61]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
809 ! CHECK: %[[VAL_70:.*]] = fir.convert %[[VAL_60]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
810 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_69]], %[[VAL_70]], %[[VAL_67]], %[[VAL_68]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
811 ! CHECK: %[[VAL_71:.*]] = arith.constant 1 : index
812 ! CHECK: %[[VAL_72:.*]] = arith.subi %[[VAL_62]], %[[VAL_71]] : index
813 ! CHECK: %[[VAL_73:.*]] = arith.constant 32 : i8
814 ! CHECK: %[[VAL_74:.*]] = fir.undefined !fir.char<1>
815 ! CHECK: %[[VAL_75:.*]] = fir.insert_value %[[VAL_74]], %[[VAL_73]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
816 ! CHECK: %[[VAL_76:.*]] = arith.constant 1 : index
817 ! CHECK: fir.do_loop %[[VAL_77:.*]] = %[[VAL_64]] to %[[VAL_72]] step %[[VAL_76]] {
818 ! CHECK: %[[VAL_78:.*]] = fir.convert %[[VAL_61]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
819 ! CHECK: %[[VAL_79:.*]] = fir.coordinate_of %[[VAL_78]], %[[VAL_77]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
820 ! CHECK: fir.store %[[VAL_75]] to %[[VAL_79]] : !fir.ref<!fir.char<1>>
822 ! CHECK: %[[VAL_80:.*]] = fir.array_amend %[[VAL_59]], %[[VAL_61]] : (!fir.array<?x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<?x!fir.char<1,10>>
823 ! CHECK: fir.result %[[VAL_80]] : !fir.array<?x!fir.char<1,10>>
825 ! CHECK: fir.array_merge_store %[[VAL_53]], %[[VAL_81:.*]] to %[[VAL_10]] : !fir.array<?x!fir.char<1,10>>, !fir.array<?x!fir.char<1,10>>, !fir.heap<!fir.array<?x!fir.char<1,10>>>
826 ! CHECK: fir.result %[[VAL_10]] : !fir.heap<!fir.array<?x!fir.char<1,10>>>
828 ! CHECK: fir.result %[[VAL_19]], %[[VAL_82:.*]] : i1, !fir.heap<!fir.array<?x!fir.char<1,10>>>
830 ! CHECK: %[[VAL_83:.*]] = arith.constant true
831 ! CHECK: %[[VAL_84:.*]] = fir.allocmem !fir.array<?x!fir.char<1,10>>, %[[VAL_6]] {uniq_name = ".auto.alloc"}
832 ! CHECK: %[[VAL_85:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
833 ! CHECK: %[[VAL_86:.*]] = fir.array_load %[[VAL_84]](%[[VAL_85]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<?x!fir.char<1,10>>
834 ! CHECK: %[[VAL_87:.*]] = arith.constant 1 : index
835 ! CHECK: %[[VAL_88:.*]] = arith.constant 0 : index
836 ! CHECK: %[[VAL_89:.*]] = arith.subi %[[VAL_6]], %[[VAL_87]] : index
837 ! CHECK: %[[VAL_90:.*]] = fir.do_loop %[[VAL_91:.*]] = %[[VAL_88]] to %[[VAL_89]] step %[[VAL_87]] unordered iter_args(%[[VAL_92:.*]] = %[[VAL_86]]) -> (!fir.array<?x!fir.char<1,10>>) {
838 ! CHECK: %[[VAL_93:.*]] = fir.array_access %[[VAL_8]], %[[VAL_91]] : (!fir.array<20x!fir.char<1,12>>, index) -> !fir.ref<!fir.char<1,12>>
839 ! CHECK: %[[VAL_94:.*]] = fir.array_access %[[VAL_92]], %[[VAL_91]] : (!fir.array<?x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
840 ! CHECK: %[[VAL_95:.*]] = arith.constant 10 : index
841 ! CHECK: %[[VAL_96:.*]] = arith.cmpi slt, %[[VAL_95]], %[[VAL_3]] : index
842 ! CHECK: %[[VAL_97:.*]] = arith.select %[[VAL_96]], %[[VAL_95]], %[[VAL_3]] : index
843 ! CHECK: %[[VAL_98:.*]] = arith.constant 1 : i64
844 ! CHECK: %[[VAL_99:.*]] = fir.convert %[[VAL_97]] : (index) -> i64
845 ! CHECK: %[[VAL_100:.*]] = arith.muli %[[VAL_98]], %[[VAL_99]] : i64
846 ! CHECK: %[[VAL_101:.*]] = arith.constant false
847 ! CHECK: %[[VAL_102:.*]] = fir.convert %[[VAL_94]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
848 ! CHECK: %[[VAL_103:.*]] = fir.convert %[[VAL_93]] : (!fir.ref<!fir.char<1,12>>) -> !fir.ref<i8>
849 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_102]], %[[VAL_103]], %[[VAL_100]], %[[VAL_101]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
850 ! CHECK: %[[VAL_104:.*]] = arith.constant 1 : index
851 ! CHECK: %[[VAL_105:.*]] = arith.subi %[[VAL_95]], %[[VAL_104]] : index
852 ! CHECK: %[[VAL_106:.*]] = arith.constant 32 : i8
853 ! CHECK: %[[VAL_107:.*]] = fir.undefined !fir.char<1>
854 ! CHECK: %[[VAL_108:.*]] = fir.insert_value %[[VAL_107]], %[[VAL_106]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
855 ! CHECK: %[[VAL_109:.*]] = arith.constant 1 : index
856 ! CHECK: fir.do_loop %[[VAL_110:.*]] = %[[VAL_97]] to %[[VAL_105]] step %[[VAL_109]] {
857 ! CHECK: %[[VAL_111:.*]] = fir.convert %[[VAL_94]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.array<10x!fir.char<1>>>
858 ! CHECK: %[[VAL_112:.*]] = fir.coordinate_of %[[VAL_111]], %[[VAL_110]] : (!fir.ref<!fir.array<10x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
859 ! CHECK: fir.store %[[VAL_108]] to %[[VAL_112]] : !fir.ref<!fir.char<1>>
861 ! CHECK: %[[VAL_113:.*]] = fir.array_amend %[[VAL_92]], %[[VAL_94]] : (!fir.array<?x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<?x!fir.char<1,10>>
862 ! CHECK: fir.result %[[VAL_113]] : !fir.array<?x!fir.char<1,10>>
864 ! CHECK: fir.array_merge_store %[[VAL_86]], %[[VAL_114:.*]] to %[[VAL_84]] : !fir.array<?x!fir.char<1,10>>, !fir.array<?x!fir.char<1,10>>, !fir.heap<!fir.array<?x!fir.char<1,10>>>
865 ! CHECK: fir.result %[[VAL_83]], %[[VAL_84]] : i1, !fir.heap<!fir.array<?x!fir.char<1,10>>>
867 ! CHECK: fir.if %[[VAL_115:.*]]#0 {
868 ! CHECK: fir.if %[[VAL_13]] {
869 ! CHECK: fir.freemem %[[VAL_10]] : !fir.heap<!fir.array<?x!fir.char<1,10>>>
871 ! CHECK: %[[VAL_116:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
872 ! CHECK: %[[VAL_117:.*]] = fir.embox %[[VAL_115]]#1(%[[VAL_116]]) : (!fir.heap<!fir.array<?x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>
873 ! CHECK: fir.store %[[VAL_117]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,10>>>>>
880 ! CHECK-LABEL: func @_QMalloc_assignPtest_dyn_char(
881 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_2:.*]]: !fir.boxchar<1>{{.*}}) {
882 subroutine test_dyn_char(x
, n
, c
)
884 character(n
), allocatable
:: x(:)
885 character(*) :: c(20)
886 ! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
887 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<20x!fir.char<1,?>>>
888 ! CHECK: %[[VAL_5:.*]] = arith.constant 20 : index
889 ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_1]] : !fir.ref<i32>
890 ! CHECK: %[[VAL_7:.*]] = arith.constant 0 : i32
891 ! CHECK: %[[VAL_8:.*]] = arith.cmpi sgt, %[[VAL_6]], %[[VAL_7]] : i32
892 ! CHECK: %[[VAL_9:.*]] = arith.select %[[VAL_8]], %[[VAL_6]], %[[VAL_7]] : i32
893 ! CHECK: %[[VAL_10:.*]] = arith.constant 20 : index
894 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
895 ! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_4]](%[[VAL_11]]) typeparams %[[VAL_3]]#1 : (!fir.ref<!fir.array<20x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<20x!fir.char<1,?>>
896 ! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
897 ! CHECK: %[[VAL_14:.*]] = fir.box_addr %[[VAL_13]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>) -> !fir.heap<!fir.array<?x!fir.char<1,?>>>
898 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>) -> i64
899 ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : i64
900 ! CHECK: %[[VAL_17:.*]] = arith.cmpi ne, %[[VAL_15]], %[[VAL_16]] : i64
901 ! CHECK: %[[VAL_18:.*]]:2 = fir.if %[[VAL_17]] -> (i1, !fir.heap<!fir.array<?x!fir.char<1,?>>>) {
902 ! CHECK: %[[VAL_19:.*]] = arith.constant false
903 ! CHECK: %[[VAL_20:.*]] = arith.constant 0 : index
904 ! CHECK: %[[VAL_21:.*]]:3 = fir.box_dims %[[VAL_13]], %[[VAL_20]] : (!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>, index) -> (index, index, index)
905 ! CHECK: %[[VAL_22:.*]] = arith.cmpi ne, %[[VAL_21]]#1, %[[VAL_10]] : index
906 ! CHECK: %[[VAL_23:.*]] = arith.select %[[VAL_22]], %[[VAL_22]], %[[VAL_19]] : i1
907 ! CHECK: %[[VAL_24:.*]] = fir.if %[[VAL_23]] -> (!fir.heap<!fir.array<?x!fir.char<1,?>>>) {
908 ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
909 ! CHECK: %[[VAL_26:.*]] = fir.allocmem !fir.array<?x!fir.char<1,?>>(%[[VAL_25]] : index), %[[VAL_10]] {uniq_name = ".auto.alloc"}
910 ! CHECK: %[[VAL_27:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
911 ! CHECK: %[[VAL_28:.*]] = fir.array_load %[[VAL_26]](%[[VAL_27]]) typeparams %[[VAL_9]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<?x!fir.char<1,?>>
912 ! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
913 ! CHECK: %[[VAL_30:.*]] = arith.constant 0 : index
914 ! CHECK: %[[VAL_31:.*]] = arith.subi %[[VAL_10]], %[[VAL_29]] : index
915 ! CHECK: %[[VAL_32:.*]] = fir.do_loop %[[VAL_33:.*]] = %[[VAL_30]] to %[[VAL_31]] step %[[VAL_29]] unordered iter_args(%[[VAL_34:.*]] = %[[VAL_28]]) -> (!fir.array<?x!fir.char<1,?>>) {
916 ! CHECK: %[[VAL_35:.*]] = fir.array_access %[[VAL_12]], %[[VAL_33]] typeparams %[[VAL_3]]#1 : (!fir.array<20x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
917 ! CHECK: %[[VAL_36:.*]] = fir.array_access %[[VAL_34]], %[[VAL_33]] typeparams %[[VAL_9]] : (!fir.array<?x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
918 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
919 ! CHECK: %[[VAL_38:.*]] = arith.cmpi slt, %[[VAL_37]], %[[VAL_3]]#1 : index
920 ! CHECK: %[[VAL_39:.*]] = arith.select %[[VAL_38]], %[[VAL_37]], %[[VAL_3]]#1 : index
921 ! CHECK: %[[VAL_40:.*]] = arith.constant 1 : i64
922 ! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_39]] : (index) -> i64
923 ! CHECK: %[[VAL_42:.*]] = arith.muli %[[VAL_40]], %[[VAL_41]] : i64
924 ! CHECK: %[[VAL_43:.*]] = arith.constant false
925 ! CHECK: %[[VAL_44:.*]] = fir.convert %[[VAL_36]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
926 ! CHECK: %[[VAL_45:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
927 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_44]], %[[VAL_45]], %[[VAL_42]], %[[VAL_43]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
928 ! CHECK: %[[VAL_46:.*]] = arith.constant 1 : i32
929 ! CHECK: %[[VAL_47:.*]] = arith.subi %[[VAL_9]], %[[VAL_46]] : i32
930 ! CHECK: %[[VAL_48:.*]] = arith.constant 32 : i8
931 ! CHECK: %[[VAL_49:.*]] = fir.undefined !fir.char<1>
932 ! CHECK: %[[VAL_50:.*]] = fir.insert_value %[[VAL_49]], %[[VAL_48]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
933 ! CHECK: %[[VAL_51:.*]] = arith.constant 1 : index
934 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_47]] : (i32) -> index
935 ! CHECK: fir.do_loop %[[VAL_53:.*]] = %[[VAL_39]] to %[[VAL_52]] step %[[VAL_51]] {
936 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_36]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
937 ! CHECK: %[[VAL_55:.*]] = fir.coordinate_of %[[VAL_54]], %[[VAL_53]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
938 ! CHECK: fir.store %[[VAL_50]] to %[[VAL_55]] : !fir.ref<!fir.char<1>>
940 ! CHECK: %[[VAL_56:.*]] = fir.array_amend %[[VAL_34]], %[[VAL_36]] : (!fir.array<?x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<?x!fir.char<1,?>>
941 ! CHECK: fir.result %[[VAL_56]] : !fir.array<?x!fir.char<1,?>>
943 ! CHECK: fir.array_merge_store %[[VAL_28]], %[[VAL_57:.*]] to %[[VAL_26]] typeparams %[[VAL_9]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.heap<!fir.array<?x!fir.char<1,?>>>, i32
944 ! CHECK: fir.result %[[VAL_26]] : !fir.heap<!fir.array<?x!fir.char<1,?>>>
946 ! CHECK: %[[VAL_58:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
947 ! CHECK: %[[VAL_59:.*]] = fir.array_load %[[VAL_14]](%[[VAL_58]]) typeparams %[[VAL_9]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<?x!fir.char<1,?>>
948 ! CHECK: %[[VAL_60:.*]] = arith.constant 1 : index
949 ! CHECK: %[[VAL_61:.*]] = arith.constant 0 : index
950 ! CHECK: %[[VAL_62:.*]] = arith.subi %[[VAL_10]], %[[VAL_60]] : index
951 ! CHECK: %[[VAL_63:.*]] = fir.do_loop %[[VAL_64:.*]] = %[[VAL_61]] to %[[VAL_62]] step %[[VAL_60]] unordered iter_args(%[[VAL_65:.*]] = %[[VAL_59]]) -> (!fir.array<?x!fir.char<1,?>>) {
952 ! CHECK: %[[VAL_66:.*]] = fir.array_access %[[VAL_12]], %[[VAL_64]] typeparams %[[VAL_3]]#1 : (!fir.array<20x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
953 ! CHECK: %[[VAL_67:.*]] = fir.array_access %[[VAL_65]], %[[VAL_64]] typeparams %[[VAL_9]] : (!fir.array<?x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
954 ! CHECK: %[[VAL_68:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
955 ! CHECK: %[[VAL_69:.*]] = arith.cmpi slt, %[[VAL_68]], %[[VAL_3]]#1 : index
956 ! CHECK: %[[VAL_70:.*]] = arith.select %[[VAL_69]], %[[VAL_68]], %[[VAL_3]]#1 : index
957 ! CHECK: %[[VAL_71:.*]] = arith.constant 1 : i64
958 ! CHECK: %[[VAL_72:.*]] = fir.convert %[[VAL_70]] : (index) -> i64
959 ! CHECK: %[[VAL_73:.*]] = arith.muli %[[VAL_71]], %[[VAL_72]] : i64
960 ! CHECK: %[[VAL_74:.*]] = arith.constant false
961 ! CHECK: %[[VAL_75:.*]] = fir.convert %[[VAL_67]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
962 ! CHECK: %[[VAL_76:.*]] = fir.convert %[[VAL_66]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
963 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_75]], %[[VAL_76]], %[[VAL_73]], %[[VAL_74]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
964 ! CHECK: %[[VAL_77:.*]] = arith.constant 1 : i32
965 ! CHECK: %[[VAL_78:.*]] = arith.subi %[[VAL_9]], %[[VAL_77]] : i32
966 ! CHECK: %[[VAL_79:.*]] = arith.constant 32 : i8
967 ! CHECK: %[[VAL_80:.*]] = fir.undefined !fir.char<1>
968 ! CHECK: %[[VAL_81:.*]] = fir.insert_value %[[VAL_80]], %[[VAL_79]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
969 ! CHECK: %[[VAL_82:.*]] = arith.constant 1 : index
970 ! CHECK: %[[VAL_83:.*]] = fir.convert %[[VAL_78]] : (i32) -> index
971 ! CHECK: fir.do_loop %[[VAL_84:.*]] = %[[VAL_70]] to %[[VAL_83]] step %[[VAL_82]] {
972 ! CHECK: %[[VAL_85:.*]] = fir.convert %[[VAL_67]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
973 ! CHECK: %[[VAL_86:.*]] = fir.coordinate_of %[[VAL_85]], %[[VAL_84]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
974 ! CHECK: fir.store %[[VAL_81]] to %[[VAL_86]] : !fir.ref<!fir.char<1>>
976 ! CHECK: %[[VAL_87:.*]] = fir.array_amend %[[VAL_65]], %[[VAL_67]] : (!fir.array<?x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<?x!fir.char<1,?>>
977 ! CHECK: fir.result %[[VAL_87]] : !fir.array<?x!fir.char<1,?>>
979 ! CHECK: fir.array_merge_store %[[VAL_59]], %[[VAL_88:.*]] to %[[VAL_14]] typeparams %[[VAL_9]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.heap<!fir.array<?x!fir.char<1,?>>>, i32
980 ! CHECK: fir.result %[[VAL_14]] : !fir.heap<!fir.array<?x!fir.char<1,?>>>
982 ! CHECK: fir.result %[[VAL_23]], %[[VAL_89:.*]] : i1, !fir.heap<!fir.array<?x!fir.char<1,?>>>
984 ! CHECK: %[[VAL_90:.*]] = arith.constant true
985 ! CHECK: %[[VAL_91:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
986 ! CHECK: %[[VAL_92:.*]] = fir.allocmem !fir.array<?x!fir.char<1,?>>(%[[VAL_91]] : index), %[[VAL_10]] {uniq_name = ".auto.alloc"}
987 ! CHECK: %[[VAL_93:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
988 ! CHECK: %[[VAL_94:.*]] = fir.array_load %[[VAL_92]](%[[VAL_93]]) typeparams %[[VAL_9]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<?x!fir.char<1,?>>
989 ! CHECK: %[[VAL_95:.*]] = arith.constant 1 : index
990 ! CHECK: %[[VAL_96:.*]] = arith.constant 0 : index
991 ! CHECK: %[[VAL_97:.*]] = arith.subi %[[VAL_10]], %[[VAL_95]] : index
992 ! CHECK: %[[VAL_98:.*]] = fir.do_loop %[[VAL_99:.*]] = %[[VAL_96]] to %[[VAL_97]] step %[[VAL_95]] unordered iter_args(%[[VAL_100:.*]] = %[[VAL_94]]) -> (!fir.array<?x!fir.char<1,?>>) {
993 ! CHECK: %[[VAL_101:.*]] = fir.array_access %[[VAL_12]], %[[VAL_99]] typeparams %[[VAL_3]]#1 : (!fir.array<20x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
994 ! CHECK: %[[VAL_102:.*]] = fir.array_access %[[VAL_100]], %[[VAL_99]] typeparams %[[VAL_9]] : (!fir.array<?x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
995 ! CHECK: %[[VAL_103:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
996 ! CHECK: %[[VAL_104:.*]] = arith.cmpi slt, %[[VAL_103]], %[[VAL_3]]#1 : index
997 ! CHECK: %[[VAL_105:.*]] = arith.select %[[VAL_104]], %[[VAL_103]], %[[VAL_3]]#1 : index
998 ! CHECK: %[[VAL_106:.*]] = arith.constant 1 : i64
999 ! CHECK: %[[VAL_107:.*]] = fir.convert %[[VAL_105]] : (index) -> i64
1000 ! CHECK: %[[VAL_108:.*]] = arith.muli %[[VAL_106]], %[[VAL_107]] : i64
1001 ! CHECK: %[[VAL_109:.*]] = arith.constant false
1002 ! CHECK: %[[VAL_110:.*]] = fir.convert %[[VAL_102]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
1003 ! CHECK: %[[VAL_111:.*]] = fir.convert %[[VAL_101]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
1004 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_110]], %[[VAL_111]], %[[VAL_108]], %[[VAL_109]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
1005 ! CHECK: %[[VAL_112:.*]] = arith.constant 1 : i32
1006 ! CHECK: %[[VAL_113:.*]] = arith.subi %[[VAL_9]], %[[VAL_112]] : i32
1007 ! CHECK: %[[VAL_114:.*]] = arith.constant 32 : i8
1008 ! CHECK: %[[VAL_115:.*]] = fir.undefined !fir.char<1>
1009 ! CHECK: %[[VAL_116:.*]] = fir.insert_value %[[VAL_115]], %[[VAL_114]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
1010 ! CHECK: %[[VAL_117:.*]] = arith.constant 1 : index
1011 ! CHECK: %[[VAL_118:.*]] = fir.convert %[[VAL_113]] : (i32) -> index
1012 ! CHECK: fir.do_loop %[[VAL_119:.*]] = %[[VAL_105]] to %[[VAL_118]] step %[[VAL_117]] {
1013 ! CHECK: %[[VAL_120:.*]] = fir.convert %[[VAL_102]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
1014 ! CHECK: %[[VAL_121:.*]] = fir.coordinate_of %[[VAL_120]], %[[VAL_119]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
1015 ! CHECK: fir.store %[[VAL_116]] to %[[VAL_121]] : !fir.ref<!fir.char<1>>
1017 ! CHECK: %[[VAL_122:.*]] = fir.array_amend %[[VAL_100]], %[[VAL_102]] : (!fir.array<?x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<?x!fir.char<1,?>>
1018 ! CHECK: fir.result %[[VAL_122]] : !fir.array<?x!fir.char<1,?>>
1020 ! CHECK: fir.array_merge_store %[[VAL_94]], %[[VAL_123:.*]] to %[[VAL_92]] typeparams %[[VAL_9]] : !fir.array<?x!fir.char<1,?>>, !fir.array<?x!fir.char<1,?>>, !fir.heap<!fir.array<?x!fir.char<1,?>>>, i32
1021 ! CHECK: fir.result %[[VAL_90]], %[[VAL_92]] : i1, !fir.heap<!fir.array<?x!fir.char<1,?>>>
1023 ! CHECK: fir.if %[[VAL_124:.*]]#0 {
1024 ! CHECK: %[[VAL_125:.*]] = fir.convert %[[VAL_9]] : (i32) -> index
1025 ! CHECK: fir.if %[[VAL_17]] {
1026 ! CHECK: fir.freemem %[[VAL_14]] : !fir.heap<!fir.array<?x!fir.char<1,?>>>
1028 ! CHECK: %[[VAL_126:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
1029 ! CHECK: %[[VAL_127:.*]] = fir.embox %[[VAL_124]]#1(%[[VAL_126]]) typeparams %[[VAL_125]] : (!fir.heap<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>
1030 ! CHECK: fir.store %[[VAL_127]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.char<1,?>>>>>
1037 ! CHECK-LABEL: func @_QMalloc_assignPtest_derived_with_init
1038 subroutine test_derived_with_init(x
, y
)
1040 integer, allocatable
:: a(:)
1042 type(t
), allocatable
:: x
1044 ! The allocatable component of `x` need to be initialized
1045 ! during the automatic allocation (setting its rank and allocation
1046 ! status) before it is assigned with the component of `y`
1048 ! CHECK: fir.if %{{.*}} {
1049 ! CHECK: %[[VAL_11:.*]] = fir.allocmem !fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}> {uniq_name = ".auto.alloc"}
1050 ! CHECK: %[[VAL_12:.*]] = fir.embox %[[VAL_11]] : (!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>) -> !fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>
1051 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_12]] : (!fir.box<!fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>>) -> !fir.box<none>
1052 ! CHECK: fir.call @_FortranAInitialize(%[[VAL_15]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32) -> none
1053 ! CHECK: fir.result %[[VAL_11]] : !fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>
1055 ! CHECK: fir.result %{{.*}} : !fir.heap<!fir.type<_QMalloc_assignFtest_derived_with_initTt{a:!fir.box<!fir.heap<!fir.array<?xi32>>>}>>
1059 ! CHECK-LABEL: func @_QMalloc_assignPtest_vector_subscript(
1060 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {fir.bindc_name = "x"},
1061 ! CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "y"},
1062 ! CHECK-SAME: %[[VAL_2:.*]]: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "v"}) {
1063 subroutine test_vector_subscript(x
, y
, v
)
1064 ! Test that the new shape is computed correctly in presence of
1065 ! vector subscripts on the RHS and that it is used to allocate
1066 ! the new storage and to drive the implicit loop.
1067 integer, allocatable
:: x(:)
1068 integer :: y(:), v(:)
1070 ! CHECK: %[[VAL_3:.*]] = arith.constant 1 : index
1071 ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
1072 ! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_4]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
1073 ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
1074 ! CHECK: %[[VAL_7:.*]]:3 = fir.box_dims %[[VAL_2]], %[[VAL_6]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
1075 ! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_2]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
1076 ! CHECK: %[[VAL_9:.*]] = arith.cmpi sgt, %[[VAL_7]]#1, %[[VAL_5]]#1 : index
1077 ! CHECK: %[[VAL_10:.*]] = arith.select %[[VAL_9]], %[[VAL_5]]#1, %[[VAL_7]]#1 : index
1078 ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?xi32>>) -> !fir.array<?xi32>
1079 ! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
1080 ! CHECK: %[[VAL_13:.*]] = fir.box_addr %[[VAL_12]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
1081 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.heap<!fir.array<?xi32>>) -> i64
1082 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : i64
1083 ! CHECK: %[[VAL_16:.*]] = arith.cmpi ne, %[[VAL_14]], %[[VAL_15]] : i64
1084 ! CHECK: %[[VAL_17:.*]]:2 = fir.if %[[VAL_16]] -> (i1, !fir.heap<!fir.array<?xi32>>) {
1085 ! CHECK: %[[VAL_18:.*]] = arith.constant false
1086 ! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
1087 ! CHECK: %[[VAL_20:.*]]:3 = fir.box_dims %[[VAL_12]], %[[VAL_19]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>, index) -> (index, index, index)
1088 ! CHECK: %[[VAL_21:.*]] = arith.cmpi ne, %[[VAL_20]]#1, %[[VAL_10]] : index
1089 ! CHECK: %[[VAL_22:.*]] = arith.select %[[VAL_21]], %[[VAL_21]], %[[VAL_18]] : i1
1090 ! CHECK: %[[VAL_23:.*]] = fir.if %[[VAL_22]] -> (!fir.heap<!fir.array<?xi32>>) {
1091 ! CHECK: %[[VAL_24:.*]] = fir.allocmem !fir.array<?xi32>, %[[VAL_10]] {uniq_name = ".auto.alloc"}
1092 ! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
1093 ! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_24]](%[[VAL_25]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.array<?xi32>
1094 ! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
1095 ! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
1096 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_10]], %[[VAL_27]] : index
1097 ! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_26]]) -> (!fir.array<?xi32>) {
1098 ! CHECK: %[[VAL_33:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_31]] : (!fir.array<?xi32>, index) -> i32
1099 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_33]] : (i32) -> index
1100 ! CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_34]], %[[VAL_3]] : index
1101 ! CHECK: %[[VAL_36:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_35]] : (!fir.array<?xi32>, index) -> i32
1102 ! CHECK: %[[VAL_37:.*]] = fir.array_update %[[VAL_32]], %[[VAL_36]], %[[VAL_31]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
1103 ! CHECK: fir.result %[[VAL_37]] : !fir.array<?xi32>
1105 ! CHECK: fir.array_merge_store %[[VAL_26]], %[[VAL_38:.*]] to %[[VAL_24]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.heap<!fir.array<?xi32>>
1106 ! CHECK: fir.result %[[VAL_24]] : !fir.heap<!fir.array<?xi32>>
1108 ! CHECK: %[[VAL_39:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
1109 ! CHECK: %[[VAL_40:.*]] = fir.array_load %[[VAL_13]](%[[VAL_39]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.array<?xi32>
1110 ! CHECK: %[[VAL_41:.*]] = arith.constant 1 : index
1111 ! CHECK: %[[VAL_42:.*]] = arith.constant 0 : index
1112 ! CHECK: %[[VAL_43:.*]] = arith.subi %[[VAL_10]], %[[VAL_41]] : index
1113 ! CHECK: %[[VAL_44:.*]] = fir.do_loop %[[VAL_45:.*]] = %[[VAL_42]] to %[[VAL_43]] step %[[VAL_41]] unordered iter_args(%[[VAL_46:.*]] = %[[VAL_40]]) -> (!fir.array<?xi32>) {
1114 ! CHECK: %[[VAL_47:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_45]] : (!fir.array<?xi32>, index) -> i32
1115 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_47]] : (i32) -> index
1116 ! CHECK: %[[VAL_49:.*]] = arith.subi %[[VAL_48]], %[[VAL_3]] : index
1117 ! CHECK: %[[VAL_50:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_49]] : (!fir.array<?xi32>, index) -> i32
1118 ! CHECK: %[[VAL_51:.*]] = fir.array_update %[[VAL_46]], %[[VAL_50]], %[[VAL_45]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
1119 ! CHECK: fir.result %[[VAL_51]] : !fir.array<?xi32>
1121 ! CHECK: fir.array_merge_store %[[VAL_40]], %[[VAL_52:.*]] to %[[VAL_13]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.heap<!fir.array<?xi32>>
1122 ! CHECK: fir.result %[[VAL_13]] : !fir.heap<!fir.array<?xi32>>
1124 ! CHECK: fir.result %[[VAL_22]], %[[VAL_53:.*]] : i1, !fir.heap<!fir.array<?xi32>>
1126 ! CHECK: %[[VAL_54:.*]] = arith.constant true
1127 ! CHECK: %[[VAL_55:.*]] = fir.allocmem !fir.array<?xi32>, %[[VAL_10]] {uniq_name = ".auto.alloc"}
1128 ! CHECK: %[[VAL_56:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
1129 ! CHECK: %[[VAL_57:.*]] = fir.array_load %[[VAL_55]](%[[VAL_56]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.array<?xi32>
1130 ! CHECK: %[[VAL_58:.*]] = arith.constant 1 : index
1131 ! CHECK: %[[VAL_59:.*]] = arith.constant 0 : index
1132 ! CHECK: %[[VAL_60:.*]] = arith.subi %[[VAL_10]], %[[VAL_58]] : index
1133 ! CHECK: %[[VAL_61:.*]] = fir.do_loop %[[VAL_62:.*]] = %[[VAL_59]] to %[[VAL_60]] step %[[VAL_58]] unordered iter_args(%[[VAL_63:.*]] = %[[VAL_57]]) -> (!fir.array<?xi32>) {
1134 ! CHECK: %[[VAL_64:.*]] = fir.array_fetch %[[VAL_8]], %[[VAL_62]] : (!fir.array<?xi32>, index) -> i32
1135 ! CHECK: %[[VAL_65:.*]] = fir.convert %[[VAL_64]] : (i32) -> index
1136 ! CHECK: %[[VAL_66:.*]] = arith.subi %[[VAL_65]], %[[VAL_3]] : index
1137 ! CHECK: %[[VAL_67:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_66]] : (!fir.array<?xi32>, index) -> i32
1138 ! CHECK: %[[VAL_68:.*]] = fir.array_update %[[VAL_63]], %[[VAL_67]], %[[VAL_62]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
1139 ! CHECK: fir.result %[[VAL_68]] : !fir.array<?xi32>
1141 ! CHECK: fir.array_merge_store %[[VAL_57]], %[[VAL_69:.*]] to %[[VAL_55]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.heap<!fir.array<?xi32>>
1142 ! CHECK: fir.result %[[VAL_54]], %[[VAL_55]] : i1, !fir.heap<!fir.array<?xi32>>
1144 ! CHECK: fir.if %[[VAL_70:.*]]#0 {
1145 ! CHECK: fir.if %[[VAL_16]] {
1146 ! CHECK: fir.freemem %[[VAL_13]] : !fir.heap<!fir.array<?xi32>>
1148 ! CHECK: %[[VAL_71:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
1149 ! CHECK: %[[VAL_72:.*]] = fir.embox %[[VAL_70]]#1(%[[VAL_71]]) : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xi32>>>
1150 ! CHECK: fir.store %[[VAL_72]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
1156 ! CHECK-LABEL: func @_QMalloc_assignPtest_both_sides_with_elemental_call(
1157 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>> {fir.bindc_name = "x"}) {
1158 subroutine test_both_sides_with_elemental_call(x
)
1160 elemental
real function elt(x
)
1161 real, intent(in
) :: x
1164 real, allocatable
:: x(:)
1166 ! CHECK: %[[VAL_1:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
1167 ! CHECK: %[[VAL_2:.*]] = arith.constant 0 : index
1168 ! CHECK: %[[VAL_3:.*]]:3 = fir.box_dims %[[VAL_1]], %[[VAL_2]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> (index, index, index)
1169 ! CHECK: %[[VAL_4:.*]] = fir.box_addr %[[VAL_1]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>) -> !fir.heap<!fir.array<?xf32>>
1170 ! CHECK: %[[VAL_5:.*]] = fir.shape_shift %[[VAL_3]]#0, %[[VAL_3]]#1 : (index, index) -> !fir.shapeshift<1>
1171 ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
1172 ! CHECK: %[[VAL_7:.*]] = fir.box_addr %[[VAL_6]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>) -> !fir.heap<!fir.array<?xf32>>
1173 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (!fir.heap<!fir.array<?xf32>>) -> i64
1174 ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i64
1175 ! CHECK: %[[VAL_10:.*]] = arith.cmpi ne, %[[VAL_8]], %[[VAL_9]] : i64
1176 ! CHECK: %[[VAL_11:.*]]:2 = fir.if %[[VAL_10]] -> (i1, !fir.heap<!fir.array<?xf32>>) {
1177 ! CHECK: %[[VAL_12:.*]] = arith.constant false
1178 ! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
1179 ! CHECK: %[[VAL_14:.*]]:3 = fir.box_dims %[[VAL_6]], %[[VAL_13]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>, index) -> (index, index, index)
1180 ! CHECK: %[[VAL_15:.*]] = arith.cmpi ne, %[[VAL_14]]#1, %[[VAL_3]]#1 : index
1181 ! CHECK: %[[VAL_16:.*]] = arith.select %[[VAL_15]], %[[VAL_15]], %[[VAL_12]] : i1
1182 ! CHECK: %[[VAL_17:.*]] = fir.if %[[VAL_16]] -> (!fir.heap<!fir.array<?xf32>>) {
1183 ! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.array<?xf32>, %[[VAL_3]]#1 {uniq_name = ".auto.alloc"}
1184 ! CHECK: %[[VAL_19:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
1185 ! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_18]](%[[VAL_19]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
1186 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
1187 ! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
1188 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_21]] : index
1189 ! CHECK: %[[VAL_24:.*]] = fir.do_loop %[[VAL_25:.*]] = %[[VAL_22]] to %[[VAL_23]] step %[[VAL_21]] unordered iter_args(%[[VAL_26:.*]] = %[[VAL_20]]) -> (!fir.array<?xf32>) {
1190 ! CHECK: %[[VAL_27:.*]] = arith.addi %[[VAL_25]], %[[VAL_3]]#0 : index
1191 ! CHECK: %[[VAL_28:.*]] = fir.array_coor %[[VAL_4]](%[[VAL_5]]) %[[VAL_27]] : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
1192 ! CHECK: %[[VAL_29:.*]] = fir.call @_QPelt(%[[VAL_28]]) {{.*}}: (!fir.ref<f32>) -> f32
1193 ! CHECK: %[[VAL_30:.*]] = fir.array_update %[[VAL_26]], %[[VAL_29]], %[[VAL_25]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
1194 ! CHECK: fir.result %[[VAL_30]] : !fir.array<?xf32>
1196 ! CHECK: fir.array_merge_store %[[VAL_20]], %[[VAL_31:.*]] to %[[VAL_18]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.heap<!fir.array<?xf32>>
1197 ! CHECK: fir.result %[[VAL_18]] : !fir.heap<!fir.array<?xf32>>
1199 ! CHECK: %[[VAL_32:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
1200 ! CHECK: %[[VAL_33:.*]] = fir.array_load %[[VAL_7]](%[[VAL_32]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
1201 ! CHECK: %[[VAL_34:.*]] = arith.constant 1 : index
1202 ! CHECK: %[[VAL_35:.*]] = arith.constant 0 : index
1203 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_34]] : index
1204 ! CHECK: %[[VAL_37:.*]] = fir.do_loop %[[VAL_38:.*]] = %[[VAL_35]] to %[[VAL_36]] step %[[VAL_34]] unordered iter_args(%[[VAL_39:.*]] = %[[VAL_33]]) -> (!fir.array<?xf32>) {
1205 ! CHECK: %[[VAL_40:.*]] = arith.addi %[[VAL_38]], %[[VAL_3]]#0 : index
1206 ! CHECK: %[[VAL_41:.*]] = fir.array_coor %[[VAL_4]](%[[VAL_5]]) %[[VAL_40]] : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
1207 ! CHECK: %[[VAL_42:.*]] = fir.call @_QPelt(%[[VAL_41]]) {{.*}}: (!fir.ref<f32>) -> f32
1208 ! CHECK: %[[VAL_43:.*]] = fir.array_update %[[VAL_39]], %[[VAL_42]], %[[VAL_38]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
1209 ! CHECK: fir.result %[[VAL_43]] : !fir.array<?xf32>
1211 ! CHECK: fir.array_merge_store %[[VAL_33]], %[[VAL_44:.*]] to %[[VAL_7]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.heap<!fir.array<?xf32>>
1212 ! CHECK: fir.result %[[VAL_7]] : !fir.heap<!fir.array<?xf32>>
1214 ! CHECK: fir.result %[[VAL_16]], %[[VAL_45:.*]] : i1, !fir.heap<!fir.array<?xf32>>
1216 ! CHECK: %[[VAL_46:.*]] = arith.constant true
1217 ! CHECK: %[[VAL_47:.*]] = fir.allocmem !fir.array<?xf32>, %[[VAL_3]]#1 {uniq_name = ".auto.alloc"}
1218 ! CHECK: %[[VAL_48:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
1219 ! CHECK: %[[VAL_49:.*]] = fir.array_load %[[VAL_47]](%[[VAL_48]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
1220 ! CHECK: %[[VAL_50:.*]] = arith.constant 1 : index
1221 ! CHECK: %[[VAL_51:.*]] = arith.constant 0 : index
1222 ! CHECK: %[[VAL_52:.*]] = arith.subi %[[VAL_3]]#1, %[[VAL_50]] : index
1223 ! CHECK: %[[VAL_53:.*]] = fir.do_loop %[[VAL_54:.*]] = %[[VAL_51]] to %[[VAL_52]] step %[[VAL_50]] unordered iter_args(%[[VAL_55:.*]] = %[[VAL_49]]) -> (!fir.array<?xf32>) {
1224 ! CHECK: %[[VAL_56:.*]] = arith.addi %[[VAL_54]], %[[VAL_3]]#0 : index
1225 ! CHECK: %[[VAL_57:.*]] = fir.array_coor %[[VAL_4]](%[[VAL_5]]) %[[VAL_56]] : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
1226 ! CHECK: %[[VAL_58:.*]] = fir.call @_QPelt(%[[VAL_57]]) {{.*}}: (!fir.ref<f32>) -> f32
1227 ! CHECK: %[[VAL_59:.*]] = fir.array_update %[[VAL_55]], %[[VAL_58]], %[[VAL_54]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
1228 ! CHECK: fir.result %[[VAL_59]] : !fir.array<?xf32>
1230 ! CHECK: fir.array_merge_store %[[VAL_49]], %[[VAL_60:.*]] to %[[VAL_47]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.heap<!fir.array<?xf32>>
1231 ! CHECK: fir.result %[[VAL_46]], %[[VAL_47]] : i1, !fir.heap<!fir.array<?xf32>>
1233 ! CHECK: fir.if %[[VAL_61:.*]]#0 {
1234 ! CHECK: fir.if %[[VAL_10]] {
1235 ! CHECK: fir.freemem %[[VAL_7]] : !fir.heap<!fir.array<?xf32>>
1237 ! CHECK: %[[VAL_62:.*]] = fir.shape %[[VAL_3]]#1 : (index) -> !fir.shape<1>
1238 ! CHECK: %[[VAL_63:.*]] = fir.embox %[[VAL_61]]#1(%[[VAL_62]]) : (!fir.heap<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.box<!fir.heap<!fir.array<?xf32>>>
1239 ! CHECK: fir.store %[[VAL_63]] to %[[VAL_0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
1245 ! CHECK: fir.global linkonce @[[error_message]] constant : !fir.char<1,76> {
1246 ! CHECK: %[[msg:.*]] = fir.string_lit "array left hand side must be allocated when the right hand side is a scalar\00"(76) : !fir.char<1,76>
1247 ! CHECK: fir.has_value %[[msg:.*]] : !fir.char<1,76>
1253 ! real :: y(2, 3) = reshape([1,2,3,4,5,6], [2,3])
1254 ! real, allocatable :: x (:, :)
1256 ! call test_with_lbounds(x, y)
1257 ! print *, x(10, 20)