[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / array-expression.f90
bloba373548f0232af9f0203f0c4f68ee02a65c10256
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 ! CHECK-LABEL: func @_QPtest1
4 subroutine test1(a,b,c,n)
5 integer :: n
6 real, intent(out) :: a(n)
7 real, intent(in) :: b(n), c(n)
8 ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
9 ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
10 ! CHECK-DAG: %[[C:.*]] = fir.array_load %arg2(%
11 ! CHECK: %[[T:.*]] = fir.do_loop
12 ! CHECK-DAG: %[[Bi:.*]] = fir.array_fetch %[[B]]
13 ! CHECK-DAG: %[[Ci:.*]] = fir.array_fetch %[[C]]
14 ! CHECK: %[[rv:.*]] = arith.addf %[[Bi]], %[[Ci]]
15 ! CHECK: fir.array_update %{{.*}}, %[[rv]], %
16 a = b + c
17 ! CHECK: fir.array_merge_store %[[A]], %[[T]] to %arg0
18 end subroutine test1
20 ! CHECK-LABEL: func @_QPtest1b
21 subroutine test1b(a,b,c,d,n)
22 integer :: n
23 real, intent(out) :: a(n)
24 real, intent(in) :: b(n), c(n), d(n)
25 ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
26 ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
27 ! CHECK-DAG: %[[C:.*]] = fir.array_load %arg2(%
28 ! CHECK-DAG: %[[D:.*]] = fir.array_load %arg3(%
29 ! CHECK: %[[T:.*]] = fir.do_loop
30 ! CHECK-DAG: %[[Bi:.*]] = fir.array_fetch %[[B]]
31 ! CHECK-DAG: %[[Ci:.*]] = fir.array_fetch %[[C]]
32 ! CHECK: %[[rv1:.*]] = arith.addf %[[Bi]], %[[Ci]]
33 ! CHECK: %[[Di:.*]] = fir.array_fetch %[[D]]
34 ! CHECK: %[[rv:.*]] = arith.addf %[[rv1]], %[[Di]]
35 ! CHECK: fir.array_update %{{.*}}, %[[rv]], %
36 a = b + c + d
37 ! CHECK: fir.array_merge_store %[[A]], %[[T]] to %arg0
38 end subroutine test1b
40 ! CHECK-LABEL: func @_QPtest2(
41 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}) {
42 ! CHECK: %[[VAL_3:.*]] = arith.constant 0 : index
43 ! CHECK: %[[VAL_4:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_3]] : (!fir.box<!fir.array<?xf32>>, index) -> (index, index, index)
44 ! CHECK: %[[VAL_5:.*]] = fir.array_load %[[VAL_0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32>
45 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_1]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32>
46 ! CHECK: %[[VAL_7:.*]] = fir.array_load %[[VAL_2]] : (!fir.box<!fir.array<?xf32>>) -> !fir.array<?xf32>
47 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
48 ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
49 ! CHECK: %[[VAL_10:.*]] = arith.subi %[[VAL_4]]#1, %[[VAL_8]] : index
50 ! CHECK: %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_9]] to %[[VAL_10]] step %[[VAL_8]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_5]]) -> (!fir.array<?xf32>) {
51 ! CHECK: %[[VAL_14:.*]] = fir.array_fetch %[[VAL_6]], %[[VAL_12]] : (!fir.array<?xf32>, index) -> f32
52 ! CHECK: %[[VAL_15:.*]] = fir.array_fetch %[[VAL_7]], %[[VAL_12]] : (!fir.array<?xf32>, index) -> f32
53 ! CHECK: %[[VAL_16:.*]] = arith.addf %[[VAL_14]], %[[VAL_15]] {{.*}}: f32
54 ! CHECK: %[[VAL_17:.*]] = fir.array_update %[[VAL_13]], %[[VAL_16]], %[[VAL_12]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
55 ! CHECK: fir.result %[[VAL_17]] : !fir.array<?xf32>
56 ! CHECK: }
57 ! CHECK: fir.array_merge_store %[[VAL_5]], %[[VAL_18:.*]] to %[[VAL_0]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.box<!fir.array<?xf32>>
58 ! CHECK: return
59 ! CHECK: }
60 subroutine test2(a,b,c)
61 real, intent(out) :: a(:)
62 real, intent(in) :: b(:), c(:)
63 a = b + c
64 end subroutine test2
66 ! CHECK-LABEL: func @_QPtest3
67 subroutine test3(a,b,c,n)
68 integer :: n
69 real, intent(out) :: a(n)
70 real, intent(in) :: b(n), c
71 ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
72 ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
73 ! CHECK-DAG: %[[C:.*]] = fir.load %arg2
74 ! CHECK: %[[T:.*]] = fir.do_loop
75 ! CHECK: %[[Bi:.*]] = fir.array_fetch %[[B]]
76 ! CHECK: %[[rv:.*]] = arith.addf %[[Bi]], %[[C]]
77 ! CHECK: %[[Ti:.*]] = fir.array_update %{{.*}}, %[[rv]], %
78 ! CHECK: fir.result %[[Ti]]
79 a = b + c
80 ! CHECK: fir.array_merge_store %[[A]], %[[T]] to %arg0
81 end subroutine test3
83 ! CHECK-LABEL: func @_QPtest4
84 subroutine test4(a,b,c)
85 ! TODO: this declaration fails in CallInterface lowering
86 ! real, allocatable, intent(out) :: a(:)
87 real :: a(100) ! FIXME: fake it for now
88 real, intent(in) :: b(:), c
89 ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
90 ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1
91 ! CHECK: fir.do_loop
92 ! CHECK: fir.array_fetch %[[B]], %
93 ! CHECK: fir.array_update
94 a = b + c
95 ! CHECK: fir.array_merge_store %[[A]], %{{.*}} to %arg0
96 end subroutine test4
98 ! CHECK-LABEL: func @_QPtest5
99 subroutine test5(a,b,c)
100 ! TODO: this declaration fails in CallInterface lowering
101 ! real, allocatable, intent(out) :: a(:)
102 ! real, pointer, intent(in) :: b(:)
103 real :: a(100), b(100) ! FIXME: fake it for now
104 real, intent(in) :: c
105 ! CHECK-DAG: %[[A:.*]] = fir.array_load %arg0(%
106 ! CHECK-DAG: %[[B:.*]] = fir.array_load %arg1(%
107 ! CHECK: fir.do_loop
108 ! CHECK: fir.array_fetch %[[B]], %
109 ! CHECK: fir.array_update
110 a = b + c
111 ! CHECK: fir.array_merge_store %[[A]], %{{.*}} to %arg0
112 end subroutine test5
114 ! CHECK-LABEL: func @_QPtest6(
115 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<f32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_4:.*]]: !fir.ref<i32>{{.*}}) {
116 ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
117 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i32) -> i64
118 ! CHECK: %[[VAL_7A:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
119 ! CHECK: %[[C0:.*]] = arith.constant 0 : index
120 ! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[VAL_7A]], %[[C0]] : index
121 ! CHECK: %[[VAL_7:.*]] = arith.select %[[CMP]], %[[VAL_7A]], %[[C0]] : index
122 ! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_4]] : !fir.ref<i32>
123 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]] : (i32) -> i64
124 ! CHECK: %[[VAL_10A:.*]] = fir.convert %[[VAL_9]] : (i64) -> index
125 ! CHECK: %[[C0_2:.*]] = arith.constant 0 : index
126 ! CHECK: %[[CMP_2:.*]] = arith.cmpi sgt, %[[VAL_10A]], %[[C0_2]] : index
127 ! CHECK: %[[VAL_10:.*]] = arith.select %[[CMP_2]], %[[VAL_10A]], %[[C0_2]] : index
128 ! CHECK: %[[VAL_11:.*]] = arith.constant 3 : i64
129 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
130 ! CHECK: %[[VAL_13:.*]] = arith.constant 4 : i64
131 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
132 ! CHECK: %[[VAL_15:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
133 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> i64
134 ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
135 ! CHECK: %[[VAL_18:.*]] = arith.constant 0 : index
136 ! CHECK: %[[VAL_19:.*]] = arith.subi %[[VAL_17]], %[[VAL_12]] : index
137 ! CHECK: %[[VAL_20:.*]] = arith.addi %[[VAL_19]], %[[VAL_14]] : index
138 ! CHECK: %[[VAL_21:.*]] = arith.divsi %[[VAL_20]], %[[VAL_14]] : index
139 ! CHECK: %[[VAL_22:.*]] = arith.cmpi sgt, %[[VAL_21]], %[[VAL_18]] : index
140 ! CHECK: %[[VAL_23:.*]] = arith.select %[[VAL_22]], %[[VAL_21]], %[[VAL_18]] : index
141 ! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
142 ! CHECK: %[[VAL_25:.*]] = fir.slice %[[VAL_12]], %[[VAL_17]], %[[VAL_14]] : (index, index, index) -> !fir.slice<1>
143 ! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_0]](%[[VAL_24]]) {{\[}}%[[VAL_25]]] : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<?xf32>
144 ! CHECK: %[[VAL_27:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
145 ! CHECK: %[[VAL_28:.*]] = fir.array_load %[[VAL_1]](%[[VAL_27]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
146 ! CHECK: %[[VAL_29:.*]] = fir.load %[[VAL_2]] : !fir.ref<f32>
147 ! CHECK: %[[VAL_30:.*]] = arith.constant 1 : index
148 ! CHECK: %[[VAL_31:.*]] = arith.constant 0 : index
149 ! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_23]], %[[VAL_30]] : index
150 ! CHECK: %[[VAL_33:.*]] = fir.do_loop %[[VAL_34:.*]] = %[[VAL_31]] to %[[VAL_32]] step %[[VAL_30]] unordered iter_args(%[[VAL_35:.*]] = %[[VAL_26]]) -> (!fir.array<?xf32>) {
151 ! CHECK: %[[VAL_36:.*]] = fir.array_fetch %[[VAL_28]], %[[VAL_34]] : (!fir.array<?xf32>, index) -> f32
152 ! CHECK: %[[VAL_37:.*]] = arith.addf %[[VAL_36]], %[[VAL_29]] {{.*}}: f32
153 ! CHECK: %[[VAL_38:.*]] = fir.array_update %[[VAL_35]], %[[VAL_37]], %[[VAL_34]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
154 ! CHECK: fir.result %[[VAL_38]] : !fir.array<?xf32>
155 ! CHECK: }
156 ! CHECK: fir.array_merge_store %[[VAL_26]], %[[VAL_39:.*]] to %[[VAL_0]]{{\[}}%[[VAL_25]]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.ref<!fir.array<?xf32>>, !fir.slice<1>
157 ! CHECK: return
158 ! CHECK: }
160 subroutine test6(a,b,c,n,m)
161 integer :: n, m
162 real, intent(out) :: a(n)
163 real, intent(in) :: b(m), c
164 a(3:n:4) = b + c
165 end subroutine test6
167 ! CHECK-LABEL: func @_QPtest6a(
168 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x50xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}) {
169 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
170 ! CHECK: %[[VAL_3:.*]] = arith.constant 50 : index
171 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
172 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
173 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_1]](%[[VAL_5]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
174 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
175 ! CHECK: %[[VAL_8:.*]] = arith.constant 4 : i64
176 ! CHECK: %[[VAL_9:.*]] = fir.undefined index
177 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_8]] : (i64) -> index
178 ! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_10]], %[[VAL_7]] : index
179 ! CHECK: %[[VAL_12:.*]] = arith.constant 41 : i64
180 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
181 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : i64
182 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
183 ! CHECK: %[[VAL_16:.*]] = arith.constant 50 : i64
184 ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
185 ! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
186 ! CHECK: %[[VAL_19:.*]] = fir.slice %[[VAL_8]], %[[VAL_9]], %[[VAL_9]], %[[VAL_13]], %[[VAL_17]], %[[VAL_15]] : (i64, index, index, index, index, index) -> !fir.slice<2>
187 ! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_0]](%[[VAL_18]]) {{\[}}%[[VAL_19]]] : (!fir.ref<!fir.array<10x50xf32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.array<10x50xf32>
188 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
189 ! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
190 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_4]], %[[VAL_21]] : index
191 ! CHECK: %[[VAL_24:.*]] = fir.do_loop %[[VAL_25:.*]] = %[[VAL_22]] to %[[VAL_23]] step %[[VAL_21]] unordered iter_args(%[[VAL_26:.*]] = %[[VAL_6]]) -> (!fir.array<10xf32>) {
192 ! CHECK: %[[VAL_27:.*]] = fir.array_fetch %[[VAL_20]], %[[VAL_11]], %[[VAL_25]] : (!fir.array<10x50xf32>, index, index) -> f32
193 ! CHECK: %[[VAL_28:.*]] = fir.array_update %[[VAL_26]], %[[VAL_27]], %[[VAL_25]] : (!fir.array<10xf32>, f32, index) -> !fir.array<10xf32>
194 ! CHECK: fir.result %[[VAL_28]] : !fir.array<10xf32>
195 ! CHECK: }
196 ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_29:.*]] to %[[VAL_1]] : !fir.array<10xf32>, !fir.array<10xf32>, !fir.ref<!fir.array<10xf32>>
197 ! CHECK: return
198 ! CHECK: }
200 subroutine test6a(a,b)
201 ! copy part of 1 row to b. a's projection has rank 1.
202 real :: a(10,50)
203 real :: b(10)
204 b = a(4,41:50)
205 end subroutine test6a
207 ! CHECK-LABEL: func @_QPtest6b(
208 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10x50xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xf32>>{{.*}}) {
209 ! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
210 ! CHECK: %[[VAL_3:.*]] = arith.constant 50 : index
211 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
212 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : index
213 ! CHECK: %[[VAL_6:.*]] = arith.constant 4 : i64
214 ! CHECK: %[[VAL_7:.*]] = fir.undefined index
215 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
216 ! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_8]], %[[VAL_5]] : index
217 ! CHECK: %[[VAL_10:.*]] = arith.constant 41 : i64
218 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i64) -> index
219 ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i64
220 ! CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_12]] : (i64) -> index
221 ! CHECK: %[[VAL_14:.*]] = arith.constant 50 : i64
222 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
223 ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
224 ! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_15]], %[[VAL_11]] : index
225 ! CHECK: %[[VAL_18:.*]] = arith.addi %[[VAL_17]], %[[VAL_13]] : index
226 ! CHECK: %[[VAL_19:.*]] = arith.divsi %[[VAL_18]], %[[VAL_13]] : index
227 ! CHECK: %[[VAL_20:.*]] = arith.cmpi sgt, %[[VAL_19]], %[[VAL_16]] : index
228 ! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_19]], %[[VAL_16]] : index
229 ! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_2]], %[[VAL_3]] : (index, index) -> !fir.shape<2>
230 ! CHECK: %[[VAL_23:.*]] = fir.slice %[[VAL_6]], %[[VAL_7]], %[[VAL_7]], %[[VAL_11]], %[[VAL_15]], %[[VAL_13]] : (i64, index, index, index, index, index) -> !fir.slice<2>
231 ! CHECK: %[[VAL_24:.*]] = fir.array_load %[[VAL_0]](%[[VAL_22]]) {{\[}}%[[VAL_23]]] : (!fir.ref<!fir.array<10x50xf32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.array<10x50xf32>
232 ! CHECK: %[[VAL_25:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
233 ! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_1]](%[[VAL_25]]) : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> !fir.array<10xf32>
234 ! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
235 ! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
236 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_21]], %[[VAL_27]] : index
237 ! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_24]]) -> (!fir.array<10x50xf32>) {
238 ! CHECK: %[[VAL_33:.*]] = fir.array_fetch %[[VAL_26]], %[[VAL_31]] : (!fir.array<10xf32>, index) -> f32
239 ! CHECK: %[[VAL_34:.*]] = fir.array_update %[[VAL_32]], %[[VAL_33]], %[[VAL_9]], %[[VAL_31]] : (!fir.array<10x50xf32>, f32, index, index) -> !fir.array<10x50xf32>
240 ! CHECK: fir.result %[[VAL_34]] : !fir.array<10x50xf32>
241 ! CHECK: }
242 ! CHECK: fir.array_merge_store %[[VAL_24]], %[[VAL_35:.*]] to %[[VAL_0]]{{\[}}%[[VAL_23]]] : !fir.array<10x50xf32>, !fir.array<10x50xf32>, !fir.ref<!fir.array<10x50xf32>>, !fir.slice<2>
243 ! CHECK: return
244 ! CHECK: }
246 subroutine test6b(a,b)
247 ! copy b to columns 41 to 50 of row 4 of a
248 real :: a(10,50)
249 real :: b(10)
250 a(4,41:50) = b
251 end subroutine test6b
253 ! CHECK-LABEL: func @_QPtest7(
254 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<?xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}) {
255 ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
256 ! CHECK: %[[VAL_4:.*]] = fir.convert %[[VAL_3]] : (i32) -> i64
257 ! CHECK: %[[VAL_5A:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
258 ! CHECK: %[[C0:.*]] = arith.constant 0 : index
259 ! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[VAL_5A]], %[[C0]] : index
260 ! CHECK: %[[VAL_5:.*]] = arith.select %[[CMP]], %[[VAL_5A]], %[[C0]] : index
261 ! CHECK: %[[VAL_6:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
262 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]] : (i32) -> i64
263 ! CHECK: %[[VAL_8A:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
264 ! CHECK: %[[C0_2:.*]] = arith.constant 0 : index
265 ! CHECK: %[[CMP_2:.*]] = arith.cmpi sgt, %[[VAL_8A]], %[[C0_2]] : index
266 ! CHECK: %[[VAL_8:.*]] = arith.select %[[CMP_2]], %[[VAL_8A]], %[[C0_2]] : index
267 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
268 ! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_0]](%[[VAL_9]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
269 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
270 ! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_0]](%[[VAL_11]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
271 ! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
272 ! CHECK: %[[VAL_14:.*]] = fir.array_load %[[VAL_1]](%[[VAL_13]]) : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> !fir.array<?xf32>
273 ! CHECK: %[[VAL_15:.*]] = arith.constant 1 : index
274 ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : index
275 ! CHECK: %[[VAL_17:.*]] = arith.subi %[[VAL_5]], %[[VAL_15]] : index
276 ! CHECK: %[[VAL_18:.*]] = fir.do_loop %[[VAL_19:.*]] = %[[VAL_16]] to %[[VAL_17]] step %[[VAL_15]] unordered iter_args(%[[VAL_20:.*]] = %[[VAL_10]]) -> (!fir.array<?xf32>) {
277 ! CHECK: %[[VAL_21:.*]] = fir.array_fetch %[[VAL_12]], %[[VAL_19]] : (!fir.array<?xf32>, index) -> f32
278 ! CHECK: %[[VAL_22:.*]] = fir.array_fetch %[[VAL_14]], %[[VAL_19]] : (!fir.array<?xf32>, index) -> f32
279 ! CHECK: %[[VAL_23:.*]] = arith.addf %[[VAL_21]], %[[VAL_22]] {{.*}}: f32
280 ! CHECK: %[[VAL_24:.*]] = fir.array_update %[[VAL_20]], %[[VAL_23]], %[[VAL_19]] : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32>
281 ! CHECK: fir.result %[[VAL_24]] : !fir.array<?xf32>
282 ! CHECK: }
283 ! CHECK: fir.array_merge_store %[[VAL_10]], %[[VAL_25:.*]] to %[[VAL_0]] : !fir.array<?xf32>, !fir.array<?xf32>, !fir.ref<!fir.array<?xf32>>
284 ! CHECK: return
285 ! CHECK: }
287 ! This is NOT a conflict. `a` appears on both the lhs and rhs here, but there
288 ! are no loop-carried dependences and no copy is needed.
289 subroutine test7(a,b,n)
290 integer :: n
291 real, intent(inout) :: a(n)
292 real, intent(in) :: b(n)
293 a = a + b
294 end subroutine test7
296 ! CHECK-LABEL: func @_QPtest8(
297 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<100xi32>>{{.*}}) {
298 ! CHECK: %[[VAL_2:.*]] = arith.constant 100 : index
299 ! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
300 ! CHECK: %[[VAL_4:.*]] = fir.array_load %[[VAL_0]](%[[VAL_3]]) : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.array<100xi32>
301 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
302 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : i64
303 ! CHECK: %[[VAL_7:.*]] = arith.subi %[[VAL_5]], %[[VAL_6]] : i64
304 ! CHECK: %[[VAL_8:.*]] = fir.coordinate_of %[[VAL_1]], %[[VAL_7]] : (!fir.ref<!fir.array<100xi32>>, i64) -> !fir.ref<i32>
305 ! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_8]] : !fir.ref<i32>
306 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
307 ! CHECK: %[[VAL_11:.*]] = arith.constant 0 : index
308 ! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_2]], %[[VAL_10]] : index
309 ! CHECK: %[[VAL_13:.*]] = fir.do_loop %[[VAL_14:.*]] = %[[VAL_11]] to %[[VAL_12]] step %[[VAL_10]] unordered iter_args(%[[VAL_15:.*]] = %[[VAL_4]]) -> (!fir.array<100xi32>) {
310 ! CHECK: %[[VAL_16:.*]] = fir.array_update %[[VAL_15]], %[[VAL_9]], %[[VAL_14]] : (!fir.array<100xi32>, i32, index) -> !fir.array<100xi32>
311 ! CHECK: fir.result %[[VAL_16]] : !fir.array<100xi32>
312 ! CHECK: }
313 ! CHECK: fir.array_merge_store %[[VAL_4]], %[[VAL_17:.*]] to %[[VAL_0]] : !fir.array<100xi32>, !fir.array<100xi32>, !fir.ref<!fir.array<100xi32>>
314 ! CHECK: return
315 ! CHECK: }
317 subroutine test8(a,b)
318 integer :: a(100), b(100)
319 a = b(1)
320 end subroutine test8
322 subroutine test10(a,b,c,d)
323 interface
324 ! Function takea an array and yields an array
325 function foo(a) result(res)
326 real :: a(:) ! FIXME: must be before res or semantics fails
327 ! as `size(a,1)` fails to resolve to the argument
328 real, dimension(size(a,1)) :: res
329 end function foo
330 end interface
331 interface
332 ! Function takes an array and yields a scalar
333 real function bar(a)
334 real :: a(:)
335 end function bar
336 end interface
337 real :: a(:), b(:), c(:), d(:)
338 ! a = b + foo(c + foo(d + bar(a)))
339 end subroutine test10
341 ! CHECK-LABEL: func @_QPtest11(
342 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[VAL_2:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[VAL_3:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}) {
343 ! CHECK: %[[VAL_4:.*]] = arith.constant 100 : index
344 ! CHECK: %[[VAL_5:.*]] = arith.constant 100 : index
345 ! CHECK: %[[VAL_6:.*]] = arith.constant 100 : index
346 ! CHECK: %[[VAL_7:.*]] = arith.constant 100 : index
347 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
348 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_0]](%[[VAL_8]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
349 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_5]] : (index) -> !fir.shape<1>
350 ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_1]](%[[VAL_10]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
351 ! CHECK: %[[VAL_12:.*]] = arith.constant 100 : index
352 ! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
353 ! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_2]](%[[VAL_14]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
354 ! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
355 ! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_3]](%[[VAL_16]]) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
356 ! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.array<100xf32>
357 ! CHECK: %[[VAL_19:.*]] = fir.shape %[[VAL_12]] : (index) -> !fir.shape<1>
358 ! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_18]](%[[VAL_19]]) : (!fir.heap<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
359 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
360 ! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
361 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_12]], %[[VAL_21]] : index
362 ! 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<100xf32>) {
363 ! CHECK: %[[VAL_27:.*]] = fir.array_fetch %[[VAL_15]], %[[VAL_25]] : (!fir.array<100xf32>, index) -> f32
364 ! CHECK: %[[VAL_28:.*]] = fir.array_fetch %[[VAL_17]], %[[VAL_25]] : (!fir.array<100xf32>, index) -> f32
365 ! CHECK: %[[VAL_29:.*]] = arith.addf %[[VAL_27]], %[[VAL_28]] {{.*}}: f32
366 ! CHECK: %[[VAL_30:.*]] = fir.array_update %[[VAL_26]], %[[VAL_29]], %[[VAL_25]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
367 ! CHECK: fir.result %[[VAL_30]] : !fir.array<100xf32>
368 ! CHECK: }
369 ! CHECK: fir.array_merge_store %[[VAL_20]], %[[VAL_31:.*]] to %[[VAL_18]] : !fir.array<100xf32>, !fir.array<100xf32>, !fir.heap<!fir.array<100xf32>>
370 ! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_18]] : (!fir.heap<!fir.array<100xf32>>) -> !fir.ref<!fir.array<100xf32>>
371 ! CHECK: %[[VAL_33:.*]] = fir.call @_QPbar(%[[VAL_32]]) {{.*}}: (!fir.ref<!fir.array<100xf32>>) -> f32
372 ! CHECK: %[[VAL_34:.*]] = arith.constant 1 : index
373 ! CHECK: %[[VAL_35:.*]] = arith.constant 0 : index
374 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_4]], %[[VAL_34]] : index
375 ! CHECK: %[[VAL_37:.*]] = fir.do_loop %[[VAL_38:.*]] = %[[VAL_35]] to %[[VAL_36]] step %[[VAL_34]] unordered iter_args(%[[VAL_39:.*]] = %[[VAL_9]]) -> (!fir.array<100xf32>) {
376 ! CHECK: %[[VAL_40:.*]] = fir.array_fetch %[[VAL_11]], %[[VAL_38]] : (!fir.array<100xf32>, index) -> f32
377 ! CHECK: %[[VAL_41:.*]] = arith.addf %[[VAL_40]], %[[VAL_33]] {{.*}}: f32
378 ! CHECK: %[[VAL_42:.*]] = fir.array_update %[[VAL_39]], %[[VAL_41]], %[[VAL_38]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
379 ! CHECK: fir.result %[[VAL_42]] : !fir.array<100xf32>
380 ! CHECK: }
381 ! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_43:.*]] to %[[VAL_0]] : !fir.array<100xf32>, !fir.array<100xf32>, !fir.ref<!fir.array<100xf32>>
382 ! CHECK: fir.freemem %[[VAL_18]]
383 ! CHECK: return
384 ! CHECK: }
386 subroutine test11(a,b,c,d)
387 real, external :: bar
388 real :: a(100), b(100), c(100), d(100)
389 a = b + bar(c + d)
390 end subroutine test11
392 ! CHECK-LABEL: func @_QPtest12
393 subroutine test12(a,b,c,d,n,m)
394 integer :: n, m
395 ! CHECK: %[[n:.*]] = fir.load %arg4
396 ! CHECK: %[[m:.*]] = fir.load %arg5
397 ! CHECK: %[[sha:.*]] = fir.shape %
398 ! CHECK: %[[A:.*]] = fir.array_load %arg0(%[[sha]])
399 ! CHECK: %[[shb:.*]] = fir.shape %
400 ! CHECK: %[[B:.*]] = fir.array_load %arg1(%[[shb]])
401 ! CHECK: %[[C:.*]] = fir.array_load %arg2(%
402 ! CHECK: %[[D:.*]] = fir.array_load %arg3(%
403 ! CHECK: %[[tmp:.*]] = fir.allocmem !fir.array<?xf32>, %{{.*}} {{{.*}}uniq_name = ".array.expr"}
404 ! CHECK: %[[T:.*]] = fir.array_load %[[tmp]](%
405 real, external :: bar
406 real :: a(n), b(n), c(m), d(m)
407 ! CHECK: %[[LOOP:.*]] = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%{{.*}} = %[[T]])
408 ! CHECK-DAG: fir.array_fetch %[[C]]
409 ! CHECK-DAG: fir.array_fetch %[[D]]
410 ! CHECK: fir.array_merge_store %[[T]], %[[LOOP]]
411 ! CHECK: %[[CALL:.*]] = fir.call @_QPbar
412 ! CHECK: %[[LOOP2:.*]] = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%{{.*}} = %[[A]])
413 ! CHECK: fir.array_fetch %[[B]]
414 ! CHECK: fir.array_merge_store %[[A]], %[[LOOP2]] to %arg0
415 a = b + bar(c + d)
416 ! CHECK: fir.freemem %[[tmp]] : !fir.heap<!fir.array<?xf32>>
417 end subroutine test12
419 ! CHECK-LABEL: func @_QPtest13
420 subroutine test13(a,b,c,d,n,m,i)
421 real :: a(n), b(m)
422 complex :: c(n), d(m)
423 ! CHECK: %[[A_shape:.*]] = fir.shape %
424 ! CHECK: %[[A:.*]] = fir.array_load %arg0(%[[A_shape]])
425 ! CHECK: %[[B_shape:.*]] = fir.shape %
426 ! CHECK: %[[B_slice:.*]] = fir.slice %
427 ! CHECK: %[[B:.*]] = fir.array_load %arg1(%[[B_shape]]) [%[[B_slice]]]
428 ! CHECK: %[[C_shape:.*]] = fir.shape %
429 ! CHECK: %[[C_slice:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} path %
430 ! CHECK: %[[C:.*]] = fir.array_load %arg2(%[[C_shape]]) [%[[C_slice]]]
431 ! CHECK: %[[D_shape:.*]] = fir.shape %
432 ! CHECK: %[[D_slice:.*]] = fir.slice %{{.*}}, %{{.*}}, %{{.*}} path %
433 ! CHECK: %[[D:.*]] = fir.array_load %arg3(%[[D_shape]]) [%[[D_slice]]]
434 ! CHECK: = arith.constant -6.2598534E+18 : f32
435 ! CHECK: %[[A_result:.*]] = fir.do_loop %{{.*}} = %{{.*}} iter_args(%[[A_in:.*]] = %[[A]]) ->
436 ! CHECK: fir.array_fetch %[[B]],
437 ! CHECK: fir.array_fetch %[[C]],
438 ! CHECK: fir.array_fetch %[[D]],
439 ! CHECK: fir.array_update %[[A_in]],
440 a = b(i:i+2*n-2:2) + c%im - d(i:i+2*n-2:2)%re + x'deadbeef'
441 ! CHECK: fir.array_merge_store %[[A]], %[[A_result]] to %arg0
442 end subroutine test13
444 ! Test elemental call to function f
445 ! CHECK-LABEL: func @_QPtest14(
446 ! CHECK-SAME: %[[a:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
447 subroutine test14(a,b)
448 ! CHECK: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
449 interface
450 real elemental function f1(i)
451 real, intent(in) :: i
452 end function f1
453 end interface
454 real :: a(100), b(100)
455 ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
456 ! CHECK: %[[ishift:.*]] = arith.addi %[[i]], %c1{{.*}} : index
457 ! CHECK: %[[tmp:.*]] = fir.array_coor %[[a]](%{{.*}}) %[[ishift]] : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>
458 ! CHECK: %[[fres:.*]] = fir.call @_QPf1(%[[tmp]]) {{.*}}: (!fir.ref<f32>) -> f32
459 ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fres]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
460 ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
461 ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
462 b = f1(a)
463 end subroutine test14
465 ! Test elemental intrinsic function (abs)
466 ! CHECK-LABEL: func @_QPtest15(
467 ! CHECK-SAME: %[[a:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
468 subroutine test15(a,b)
469 ! CHECK-DAG: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
470 ! CHECK-DAG: %[[aarr:.*]] = fir.array_load %[[a]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
471 real :: a(100), b(100)
472 ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
473 ! CHECK: %[[val:.*]] = fir.array_fetch %[[aarr]], %[[i]] : (!fir.array<100xf32>, index) -> f32
474 ! CHECK: %[[fres:.*]] = math.absf %[[val]] {{.*}}: f32
475 ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fres]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
476 ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
477 ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
478 b = abs(a)
479 end subroutine test15
481 ! Test elemental call to function f2 with VALUE attribute
482 ! CHECK-LABEL: func @_QPtest16(
483 ! CHECK-SAME: %[[a:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
484 subroutine test16(a,b)
485 ! CHECK-DAG: %[[aarr:.*]] = fir.array_load %[[a]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
486 ! CHECK-DAG: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
487 interface
488 real elemental function f2(i)
489 real, VALUE :: i
490 end function f2
491 end interface
492 real :: a(100), b(100)
493 ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
494 ! CHECK: %[[val:.*]] = fir.array_fetch %[[aarr]], %[[i]] : (!fir.array<100xf32>, index) -> f32
495 ! CHECK: %[[fres:.*]] = fir.call @_QPf2(%[[val]]) {{.*}}: (f32) -> f32
496 ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fres]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
497 ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
498 ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
499 b = f2(a)
500 end subroutine test16
502 ! Test elemental impure call to function f3.
504 ! CHECK-LABEL: func @_QPtest17(
505 ! CHECK-SAME: %[[a:[^:]+]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[b:[^:]+]]: !fir.ref<!fir.array<100xf32>>{{.*}}, %[[c:.*]]: !fir.ref<!fir.array<100xf32>>{{.*}})
506 subroutine test17(a,b,c)
507 ! CHECK-DAG: %[[aarr:.*]] = fir.array_load %[[a]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>) -> !fir.array<100xf32>
508 ! CHECK-DAG: %[[barr:.*]] = fir.array_load %[[b]](%{{.*}}) : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>) -> !fir.array<100xf32>
509 interface
510 real elemental impure function f3(i,j,k)
511 real, intent(inout) :: i, j, k
512 end function f3
513 end interface
514 real :: a(100), b(2:101), c(3:102)
515 ! CHECK: %[[loop:.*]] = fir.do_loop %[[i:.*]] = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%[[bth:.*]] = %[[barr]]) -> (!fir.array<100xf32>) {
516 ! CHECK-DAG: %[[val:.*]] = fir.array_fetch %[[aarr]], %[[i]] : (!fir.array<100xf32>, index) -> f32
517 ! CHECK-DAG: %[[ic:.*]] = arith.addi %[[i]], %c3{{.*}} : index
518 ! CHECK-DAG: %[[ccoor:.*]] = fir.array_coor %[[c]](%{{.*}}) %[[ic]] : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
519 ! CHECK-DAG: %[[ib:.*]] = arith.addi %[[i]], %c2{{.*}} : index
520 ! CHECK-DAG: %[[bcoor:.*]] = fir.array_coor %[[b]](%{{.*}}) %[[ib]] : (!fir.ref<!fir.array<100xf32>>, !fir.shapeshift<1>, index) -> !fir.ref<f32>
521 ! CHECK-DAG: %[[ia:.*]] = arith.addi %[[i]], %c1{{.*}} : index
522 ! CHECK-DAG: %[[acoor:.*]] = fir.array_coor %[[a]](%{{.*}}) %[[ia]] : (!fir.ref<!fir.array<100xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>
523 ! CHECK: %[[fres:.*]] = fir.call @_QPf3(%[[ccoor]], %[[bcoor]], %[[acoor]]) {{.*}}: (!fir.ref<f32>, !fir.ref<f32>, !fir.ref<f32>) -> f32
524 ! CHECK: %[[fadd:.*]] = arith.addf %[[val]], %[[fres]] {{.*}}: f32
525 ! CHECK: %[[res:.*]] = fir.array_update %[[bth]], %[[fadd]], %[[i]] : (!fir.array<100xf32>, f32, index) -> !fir.array<100xf32>
527 ! See 10.1.4.p2 note 1. The expression below is illegal if `f3` defines the
528 ! argument `a` for this statement. Since, this cannot be proven statically by
529 ! the compiler, the constraint is left to the user. The compiler may give a
530 ! warning that `k` is neither VALUE nor INTENT(IN) and the actual argument,
531 ! `a`, appears elsewhere in the same statement.
532 b = a + f3(c, b, a)
534 ! CHECK: fir.result %[[res]] : !fir.array<100xf32>
535 ! CHECK: fir.array_merge_store %[[barr]], %[[loop]] to %[[b]]
536 end subroutine test17
538 ! CHECK-LABEL: func @_QPtest18() {
539 ! CHECK: %[[VAL_0:.*]] = arith.constant 10 : index
540 ! CHECK: %[[VAL_1:.*]] = arith.constant 10 : index
541 ! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.array<10x10xi32> {bindc_name = "array", fir.target, uniq_name = "_QFtest18Earray"}
542 ! CHECK: %[[VAL_3:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFtest18Ei"}
543 ! CHECK: %[[VAL_4:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xi32>>> {bindc_name = "row_i", uniq_name = "_QFtest18Erow_i"}
544 ! CHECK: %[[VAL_5:.*]] = fir.zero_bits !fir.ptr<!fir.array<?xi32>>
545 ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : index
546 ! CHECK: %[[VAL_7:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
547 ! CHECK: %[[VAL_8:.*]] = fir.embox %[[VAL_5]](%[[VAL_7]]) : (!fir.ptr<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
548 ! CHECK: fir.store %[[VAL_8]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
549 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
550 ! CHECK: %[[VAL_10:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
551 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (i32) -> i64
552 ! CHECK: %[[VAL_12:.*]] = fir.undefined index
553 ! CHECK: %[[VAL_13:.*]] = arith.constant 1 : i64
554 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i64) -> index
555 ! CHECK: %[[VAL_15:.*]] = arith.addi %[[VAL_9]], %[[VAL_1]] : index
556 ! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_15]], %[[VAL_9]] : index
557 ! CHECK: %[[VAL_17:.*]] = fir.shape %[[VAL_0]], %[[VAL_1]] : (index, index) -> !fir.shape<2>
558 ! CHECK: %[[VAL_18:.*]] = fir.slice %[[VAL_11]], %[[VAL_12]], %[[VAL_12]], %[[VAL_9]], %[[VAL_16]], %[[VAL_14]] : (i64, index, index, index, index, index) -> !fir.slice<2>
559 ! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_2]](%[[VAL_17]]) {{\[}}%[[VAL_18]]] : (!fir.ref<!fir.array<10x10xi32>>, !fir.shape<2>, !fir.slice<2>) -> !fir.box<!fir.array<?xi32>>
560 ! CHECK: %[[VAL_20:.*]] = fir.rebox %[[VAL_19]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.ptr<!fir.array<?xi32>>>
561 ! CHECK: fir.store %[[VAL_20]] to %[[VAL_4]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
562 ! CHECK: return
563 ! CHECK: }
565 subroutine test18
566 integer, target :: array(10,10)
567 integer, pointer :: row_i(:)
568 row_i => array(i, :)
569 end subroutine test18
571 ! CHECK-LABEL: func @_QPtest_column_and_row_order(
572 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<2x3xf32>>{{.*}}) {
573 ! CHECK: %[[VAL_1:.*]] = arith.constant 2 : index
574 ! CHECK: %[[VAL_2:.*]] = arith.constant 3 : index
575 ! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_1]], %[[VAL_2]] : (index, index) -> !fir.shape<2>
576 ! CHECK: %[[VAL_4:.*]] = fir.array_load %[[VAL_0]](%[[VAL_3]]) : (!fir.ref<!fir.array<2x3xf32>>, !fir.shape<2>) -> !fir.array<2x3xf32>
577 ! CHECK: %[[VAL_6:.*]] = arith.constant 4.200000e+01 : f32
578 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
579 ! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index
580 ! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_1]], %[[VAL_7]] : index
581 ! CHECK: %[[VAL_10:.*]] = arith.subi %[[VAL_2]], %[[VAL_7]] : index
582 ! CHECK: %[[VAL_11:.*]] = fir.do_loop %[[VAL_12:.*]] = %[[VAL_8]] to %[[VAL_10]] step %[[VAL_7]] unordered iter_args(%[[VAL_13:.*]] = %[[VAL_4]]) -> (!fir.array<2x3xf32>) {
583 ! CHECK: %[[VAL_14:.*]] = fir.do_loop %[[VAL_15:.*]] = %[[VAL_8]] to %[[VAL_9]] step %[[VAL_7]] unordered iter_args(%[[VAL_16:.*]] = %[[VAL_13]]) -> (!fir.array<2x3xf32>) {
584 ! CHECK: %[[VAL_17:.*]] = fir.array_update %[[VAL_16]], %[[VAL_6]], %[[VAL_15]], %[[VAL_12]] : (!fir.array<2x3xf32>, f32, index, index) -> !fir.array<2x3xf32>
585 ! CHECK: fir.result %[[VAL_17]] : !fir.array<2x3xf32>
586 ! CHECK: }
587 ! CHECK: fir.result %[[VAL_18:.*]] : !fir.array<2x3xf32>
588 ! CHECK: }
589 ! CHECK: fir.array_merge_store %[[VAL_4]], %[[VAL_19:.*]] to %[[VAL_0]] : !fir.array<2x3xf32>, !fir.array<2x3xf32>, !fir.ref<!fir.array<2x3xf32>>
590 ! CHECK: return
591 ! CHECK: }
593 subroutine test_column_and_row_order(x)
594 real :: x(2,3)
595 x = 42
596 end subroutine
598 ! CHECK-LABEL: func @_QPtest_assigning_to_assumed_shape_slices(
599 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}) {
600 ! CHECK: %[[VAL_1:.*]] = arith.constant 1 : index
601 ! CHECK: %[[VAL_2:.*]] = arith.constant 2 : i64
602 ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]] : (i64) -> index
603 ! CHECK: %[[VAL_4:.*]] = arith.constant 0 : index
604 ! CHECK: %[[VAL_5:.*]]:3 = fir.box_dims %[[VAL_0]], %[[VAL_4]] : (!fir.box<!fir.array<?xi32>>, index) -> (index, index, index)
605 ! CHECK: %[[VAL_6:.*]] = arith.addi %[[VAL_1]], %[[VAL_5]]#1 : index
606 ! CHECK: %[[VAL_7:.*]] = arith.subi %[[VAL_6]], %[[VAL_1]] : index
607 ! CHECK: %[[VAL_8:.*]] = arith.constant 0 : index
608 ! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_7]], %[[VAL_1]] : index
609 ! CHECK: %[[VAL_10:.*]] = arith.addi %[[VAL_9]], %[[VAL_3]] : index
610 ! CHECK: %[[VAL_11:.*]] = arith.divsi %[[VAL_10]], %[[VAL_3]] : index
611 ! CHECK: %[[VAL_12:.*]] = arith.cmpi sgt, %[[VAL_11]], %[[VAL_8]] : index
612 ! CHECK: %[[VAL_13:.*]] = arith.select %[[VAL_12]], %[[VAL_11]], %[[VAL_8]] : index
613 ! CHECK: %[[VAL_14:.*]] = fir.slice %[[VAL_1]], %[[VAL_7]], %[[VAL_3]] : (index, index, index) -> !fir.slice<1>
614 ! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_0]] {{\[}}%[[VAL_14]]] : (!fir.box<!fir.array<?xi32>>, !fir.slice<1>) -> !fir.array<?xi32>
615 ! CHECK: %[[VAL_16:.*]] = arith.constant 42 : i32
616 ! CHECK: %[[VAL_17:.*]] = arith.constant 1 : index
617 ! CHECK: %[[VAL_18:.*]] = arith.constant 0 : index
618 ! CHECK: %[[VAL_19:.*]] = arith.subi %[[VAL_13]], %[[VAL_17]] : index
619 ! CHECK: %[[VAL_20:.*]] = fir.do_loop %[[VAL_21:.*]] = %[[VAL_18]] to %[[VAL_19]] step %[[VAL_17]] unordered iter_args(%[[VAL_22:.*]] = %[[VAL_15]]) -> (!fir.array<?xi32>) {
620 ! CHECK: %[[VAL_23:.*]] = fir.array_update %[[VAL_22]], %[[VAL_16]], %[[VAL_21]] : (!fir.array<?xi32>, i32, index) -> !fir.array<?xi32>
621 ! CHECK: fir.result %[[VAL_23]] : !fir.array<?xi32>
622 ! CHECK: }
623 ! CHECK: fir.array_merge_store %[[VAL_15]], %[[VAL_24:.*]] to %[[VAL_0]]{{\[}}%[[VAL_14]]] : !fir.array<?xi32>, !fir.array<?xi32>, !fir.box<!fir.array<?xi32>>, !fir.slice<1>
624 ! CHECK: return
625 ! CHECK: }
627 subroutine test_assigning_to_assumed_shape_slices(x)
628 integer :: x(:)
629 x(::2) = 42
630 end subroutine
632 ! CHECK-LABEL: func @_QPtest19a(
633 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
634 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
635 ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
636 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
637 ! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
638 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
639 ! CHECK: %[[VAL_7:.*]] = arith.constant 10 : index
640 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
641 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<10x!fir.char<1,10>>
642 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
643 ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_6]](%[[VAL_10]]) : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>) -> !fir.array<10x!fir.char<1,10>>
644 ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
645 ! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
646 ! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_4]], %[[VAL_12]] : index
647 ! CHECK: %[[VAL_15:.*]] = fir.do_loop %[[VAL_16:.*]] = %[[VAL_13]] to %[[VAL_14]] step %[[VAL_12]] unordered iter_args(%[[VAL_17:.*]] = %[[VAL_9]]) -> (!fir.array<10x!fir.char<1,10>>) {
648 ! CHECK: %[[VAL_18:.*]] = fir.array_access %[[VAL_11]], %[[VAL_16]] : (!fir.array<10x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
649 ! CHECK: %[[VAL_19:.*]] = fir.array_access %[[VAL_17]], %[[VAL_16]] : (!fir.array<10x!fir.char<1,10>>, index) -> !fir.ref<!fir.char<1,10>>
650 ! CHECK: %[[VAL_20:.*]] = arith.constant 10 : index
651 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : i64
652 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (index) -> i64
653 ! CHECK: %[[VAL_23:.*]] = arith.muli %[[VAL_21]], %[[VAL_22]] : i64
654 ! CHECK: %[[VAL_24:.*]] = arith.constant false
655 ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
656 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
657 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_25]], %[[VAL_26]], %[[VAL_23]], %[[VAL_24]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
658 ! CHECK: %[[VAL_27:.*]] = fir.array_amend %[[VAL_17]], %[[VAL_19]] : (!fir.array<10x!fir.char<1,10>>, !fir.ref<!fir.char<1,10>>) -> !fir.array<10x!fir.char<1,10>>
659 ! CHECK: fir.result %[[VAL_27]] : !fir.array<10x!fir.char<1,10>>
660 ! CHECK: }
661 ! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_28:.*]] to %[[VAL_3]] : !fir.array<10x!fir.char<1,10>>, !fir.array<10x!fir.char<1,10>>, !fir.ref<!fir.array<10x!fir.char<1,10>>>
662 ! CHECK: return
663 ! CHECK: }
665 subroutine test19a(a,b)
666 character(LEN=10) a(10)
667 character(LEN=10) b(10)
668 a = b
669 end subroutine test19a
671 ! CHECK-LABEL: func @_QPtest19b(
672 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<2>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<2>{{.*}}) {
673 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<2>) -> (!fir.ref<!fir.char<2,?>>, index)
674 ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<2,?>>) -> !fir.ref<!fir.array<20x!fir.char<2,8>>>
675 ! CHECK: %[[VAL_4:.*]] = arith.constant 20 : index
676 ! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<2>) -> (!fir.ref<!fir.char<2,?>>, index)
677 ! CHECK: %[[VAL_6:.*]] = arith.constant 10 : index
678 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<2,?>>) -> !fir.ref<!fir.array<20x!fir.char<2,10>>>
679 ! CHECK: %[[VAL_8:.*]] = arith.constant 20 : index
680 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
681 ! CHECK: %[[VAL_10:.*]] = fir.array_load %[[VAL_3]](%[[VAL_9]]) : (!fir.ref<!fir.array<20x!fir.char<2,8>>>, !fir.shape<1>) -> !fir.array<20x!fir.char<2,8>>
682 ! CHECK: %[[VAL_11:.*]] = fir.shape %[[VAL_8]] : (index) -> !fir.shape<1>
683 ! CHECK: %[[VAL_12:.*]] = fir.array_load %[[VAL_7]](%[[VAL_11]]) : (!fir.ref<!fir.array<20x!fir.char<2,10>>>, !fir.shape<1>) -> !fir.array<20x!fir.char<2,10>>
684 ! CHECK: %[[VAL_13:.*]] = arith.constant 1 : index
685 ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
686 ! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_4]], %[[VAL_13]] : index
687 ! CHECK: %[[VAL_16:.*]] = fir.do_loop %[[VAL_17:.*]] = %[[VAL_14]] to %[[VAL_15]] step %[[VAL_13]] unordered iter_args(%[[VAL_18:.*]] = %[[VAL_10]]) -> (!fir.array<20x!fir.char<2,8>>) {
688 ! CHECK: %[[VAL_19:.*]] = fir.array_access %[[VAL_12]], %[[VAL_17]] : (!fir.array<20x!fir.char<2,10>>, index) -> !fir.ref<!fir.char<2,10>>
689 ! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_18]], %[[VAL_17]] : (!fir.array<20x!fir.char<2,8>>, index) -> !fir.ref<!fir.char<2,8>>
690 ! CHECK: %[[VAL_21:.*]] = arith.constant 8 : index
691 ! CHECK: %[[VAL_22:.*]] = arith.cmpi slt, %[[VAL_21]], %[[VAL_6]] : index
692 ! CHECK: %[[VAL_23:.*]] = arith.select %[[VAL_22]], %[[VAL_21]], %[[VAL_6]] : index
693 ! CHECK: %[[VAL_24:.*]] = arith.constant 2 : i64
694 ! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_23]] : (index) -> i64
695 ! CHECK: %[[VAL_26:.*]] = arith.muli %[[VAL_24]], %[[VAL_25]] : i64
696 ! CHECK: %[[VAL_27:.*]] = arith.constant false
697 ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<2,8>>) -> !fir.ref<i8>
698 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<2,10>>) -> !fir.ref<i8>
699 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_28]], %[[VAL_29]], %[[VAL_26]], %[[VAL_27]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
700 ! CHECK: %[[VAL_30:.*]] = arith.constant 1 : index
701 ! CHECK: %[[VAL_31:.*]] = arith.subi %[[VAL_21]], %[[VAL_30]] : index
702 ! CHECK: %[[VAL_32:.*]] = arith.constant 32 : i16
703 ! CHECK: %[[VAL_33:.*]] = fir.undefined !fir.char<2>
704 ! CHECK: %[[VAL_34:.*]] = fir.insert_value %[[VAL_33]], %[[VAL_32]], [0 : index] : (!fir.char<2>, i16) -> !fir.char<2>
705 ! CHECK: %[[VAL_35:.*]] = arith.constant 1 : index
706 ! CHECK: fir.do_loop %[[VAL_36:.*]] = %[[VAL_23]] to %[[VAL_31]] step %[[VAL_35]] {
707 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<2,8>>) -> !fir.ref<!fir.array<8x!fir.char<2>>>
708 ! CHECK: %[[VAL_38:.*]] = fir.coordinate_of %[[VAL_37]], %[[VAL_36]] : (!fir.ref<!fir.array<8x!fir.char<2>>>, index) -> !fir.ref<!fir.char<2>>
709 ! CHECK: fir.store %[[VAL_34]] to %[[VAL_38]] : !fir.ref<!fir.char<2>>
710 ! CHECK: }
711 ! CHECK: %[[VAL_39:.*]] = fir.array_amend %[[VAL_18]], %[[VAL_20]] : (!fir.array<20x!fir.char<2,8>>, !fir.ref<!fir.char<2,8>>) -> !fir.array<20x!fir.char<2,8>>
712 ! CHECK: fir.result %[[VAL_39]] : !fir.array<20x!fir.char<2,8>>
713 ! CHECK: }
714 ! CHECK: fir.array_merge_store %[[VAL_10]], %[[VAL_40:.*]] to %[[VAL_3]] : !fir.array<20x!fir.char<2,8>>, !fir.array<20x!fir.char<2,8>>, !fir.ref<!fir.array<20x!fir.char<2,8>>>
715 ! CHECK: return
716 ! CHECK: }
718 subroutine test19b(a,b)
719 character(KIND=2, LEN=8) a(20)
720 character(KIND=2, LEN=10) b(20)
721 a = b
722 end subroutine test19b
724 ! CHECK-LABEL: func @_QPtest19c(
725 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<4>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<4>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}) {
726 ! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<4>) -> (!fir.ref<!fir.char<4,?>>, index)
727 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
728 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<30x!fir.char<4,10>>>
729 ! CHECK: %[[VAL_6:.*]] = arith.constant 30 : index
730 ! CHECK: %[[VAL_7:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<4>) -> (!fir.ref<!fir.char<4,?>>, index)
731 ! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
732 ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i32
733 ! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_9]] : i32
734 ! CHECK: %[[VAL_11:.*]] = arith.select %[[VAL_10]], %[[VAL_8]], %[[VAL_9]] : i32
735 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<30x!fir.char<4,?>>>
736 ! CHECK: %[[VAL_13:.*]] = arith.constant 30 : index
737 ! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
738 ! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_12]](%[[VAL_14]]) typeparams %[[VAL_11]] : (!fir.ref<!fir.array<30x!fir.char<4,?>>>, !fir.shape<1>, i32) -> !fir.array<30x!fir.char<4,?>>
739 ! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
740 ! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_5]](%[[VAL_16]]) : (!fir.ref<!fir.array<30x!fir.char<4,10>>>, !fir.shape<1>) -> !fir.array<30x!fir.char<4,10>>
741 ! CHECK: %[[VAL_18:.*]] = arith.constant 1 : index
742 ! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
743 ! CHECK: %[[VAL_20:.*]] = arith.subi %[[VAL_13]], %[[VAL_18]] : index
744 ! CHECK: %[[VAL_21:.*]] = fir.do_loop %[[VAL_22:.*]] = %[[VAL_19]] to %[[VAL_20]] step %[[VAL_18]] unordered iter_args(%[[VAL_23:.*]] = %[[VAL_15]]) -> (!fir.array<30x!fir.char<4,?>>) {
745 ! CHECK: %[[VAL_24:.*]] = fir.array_access %[[VAL_17]], %[[VAL_22]] : (!fir.array<30x!fir.char<4,10>>, index) -> !fir.ref<!fir.char<4,10>>
746 ! CHECK: %[[VAL_25:.*]] = fir.array_access %[[VAL_23]], %[[VAL_22]] typeparams %[[VAL_11]] : (!fir.array<30x!fir.char<4,?>>, index, i32) -> !fir.ref<!fir.char<4,?>>
747 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_11]] : (i32) -> index
748 ! CHECK: %[[VAL_27:.*]] = arith.cmpi slt, %[[VAL_26]], %[[VAL_4]] : index
749 ! CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_26]], %[[VAL_4]] : index
750 ! CHECK: %[[VAL_29:.*]] = arith.constant 4 : i64
751 ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_28]] : (index) -> i64
752 ! CHECK: %[[VAL_31:.*]] = arith.muli %[[VAL_29]], %[[VAL_30]] : i64
753 ! CHECK: %[[VAL_32:.*]] = arith.constant false
754 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<i8>
755 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<4,10>>) -> !fir.ref<i8>
756 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_33]], %[[VAL_34]], %[[VAL_31]], %[[VAL_32]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
757 ! CHECK: %[[VAL_35:.*]] = arith.constant 1 : i32
758 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_11]], %[[VAL_35]] : i32
759 ! CHECK: %[[VAL_37:.*]] = arith.constant 32 : i32
760 ! CHECK: %[[VAL_38:.*]] = fir.undefined !fir.char<4>
761 ! CHECK: %[[VAL_39:.*]] = fir.insert_value %[[VAL_38]], %[[VAL_37]], [0 : index] : (!fir.char<4>, i32) -> !fir.char<4>
762 ! CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
763 ! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_36]] : (i32) -> index
764 ! CHECK: fir.do_loop %[[VAL_42:.*]] = %[[VAL_28]] to %[[VAL_41]] step %[[VAL_40]] {
765 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<?x!fir.char<4>>>
766 ! CHECK: %[[VAL_44:.*]] = fir.coordinate_of %[[VAL_43]], %[[VAL_42]] : (!fir.ref<!fir.array<?x!fir.char<4>>>, index) -> !fir.ref<!fir.char<4>>
767 ! CHECK: fir.store %[[VAL_39]] to %[[VAL_44]] : !fir.ref<!fir.char<4>>
768 ! CHECK: }
769 ! CHECK: %[[VAL_45:.*]] = fir.array_amend %[[VAL_23]], %[[VAL_25]] : (!fir.array<30x!fir.char<4,?>>, !fir.ref<!fir.char<4,?>>) -> !fir.array<30x!fir.char<4,?>>
770 ! CHECK: fir.result %[[VAL_45]] : !fir.array<30x!fir.char<4,?>>
771 ! CHECK: }
772 ! CHECK: fir.array_merge_store %[[VAL_15]], %[[VAL_46:.*]] to %[[VAL_12]] typeparams %[[VAL_11]] : !fir.array<30x!fir.char<4,?>>, !fir.array<30x!fir.char<4,?>>, !fir.ref<!fir.array<30x!fir.char<4,?>>>, i32
773 ! CHECK: return
774 ! CHECK: }
776 subroutine test19c(a,b,i)
777 character(KIND=4, LEN=i) a(30)
778 character(KIND=4, LEN=10) b(30)
779 a = b
780 end subroutine test19c
782 ! CHECK-LABEL: func @_QPtest19d(
783 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<i32>{{.*}}) {
784 ! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
785 ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
786 ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32
787 ! CHECK: %[[VAL_7:.*]] = arith.cmpi sgt, %[[VAL_5]], %[[VAL_6]] : i32
788 ! CHECK: %[[VAL_8:.*]] = arith.select %[[VAL_7]], %[[VAL_5]], %[[VAL_6]] : i32
789 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<40x!fir.char<1,?>>>
790 ! CHECK: %[[VAL_10:.*]] = arith.constant 40 : index
791 ! CHECK: %[[VAL_11:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
792 ! CHECK: %[[VAL_12:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
793 ! CHECK: %[[VAL_13:.*]] = arith.constant 0 : i32
794 ! CHECK: %[[VAL_14:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_13]] : i32
795 ! CHECK: %[[VAL_15:.*]] = arith.select %[[VAL_14]], %[[VAL_12]], %[[VAL_13]] : i32
796 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_11]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<40x!fir.char<1,?>>>
797 ! CHECK: %[[VAL_17:.*]] = arith.constant 40 : index
798 ! CHECK: %[[VAL_18:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
799 ! CHECK: %[[VAL_19:.*]] = fir.array_load %[[VAL_9]](%[[VAL_18]]) typeparams %[[VAL_8]] : (!fir.ref<!fir.array<40x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<40x!fir.char<1,?>>
800 ! CHECK: %[[VAL_20:.*]] = fir.shape %[[VAL_17]] : (index) -> !fir.shape<1>
801 ! CHECK: %[[VAL_21:.*]] = fir.array_load %[[VAL_16]](%[[VAL_20]]) typeparams %[[VAL_15]] : (!fir.ref<!fir.array<40x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<40x!fir.char<1,?>>
802 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : index
803 ! CHECK: %[[VAL_23:.*]] = arith.constant 0 : index
804 ! CHECK: %[[VAL_24:.*]] = arith.subi %[[VAL_10]], %[[VAL_22]] : index
805 ! CHECK: %[[VAL_25:.*]] = fir.do_loop %[[VAL_26:.*]] = %[[VAL_23]] to %[[VAL_24]] step %[[VAL_22]] unordered iter_args(%[[VAL_27:.*]] = %[[VAL_19]]) -> (!fir.array<40x!fir.char<1,?>>) {
806 ! CHECK: %[[VAL_28:.*]] = fir.array_access %[[VAL_21]], %[[VAL_26]] typeparams %[[VAL_15]] : (!fir.array<40x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
807 ! CHECK: %[[VAL_29:.*]] = fir.array_access %[[VAL_27]], %[[VAL_26]] typeparams %[[VAL_8]] : (!fir.array<40x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
808 ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_8]] : (i32) -> index
809 ! CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_15]] : (i32) -> index
810 ! CHECK: %[[VAL_32:.*]] = arith.cmpi slt, %[[VAL_30]], %[[VAL_31]] : index
811 ! CHECK: %[[VAL_33:.*]] = arith.select %[[VAL_32]], %[[VAL_30]], %[[VAL_31]] : index
812 ! CHECK: %[[VAL_34:.*]] = arith.constant 1 : i64
813 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_33]] : (index) -> i64
814 ! CHECK: %[[VAL_36:.*]] = arith.muli %[[VAL_34]], %[[VAL_35]] : i64
815 ! CHECK: %[[VAL_37:.*]] = arith.constant false
816 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
817 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
818 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_38]], %[[VAL_39]], %[[VAL_36]], %[[VAL_37]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
819 ! CHECK: %[[VAL_40:.*]] = arith.constant 1 : i32
820 ! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_8]], %[[VAL_40]] : i32
821 ! CHECK: %[[VAL_42:.*]] = arith.constant 32 : i8
822 ! CHECK: %[[VAL_43:.*]] = fir.undefined !fir.char<1>
823 ! CHECK: %[[VAL_44:.*]] = fir.insert_value %[[VAL_43]], %[[VAL_42]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
824 ! CHECK: %[[VAL_45:.*]] = arith.constant 1 : index
825 ! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_41]] : (i32) -> index
826 ! CHECK: fir.do_loop %[[VAL_47:.*]] = %[[VAL_33]] to %[[VAL_46]] step %[[VAL_45]] {
827 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
828 ! CHECK: %[[VAL_49:.*]] = fir.coordinate_of %[[VAL_48]], %[[VAL_47]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
829 ! CHECK: fir.store %[[VAL_44]] to %[[VAL_49]] : !fir.ref<!fir.char<1>>
830 ! CHECK: }
831 ! CHECK: %[[VAL_50:.*]] = fir.array_amend %[[VAL_27]], %[[VAL_29]] : (!fir.array<40x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<40x!fir.char<1,?>>
832 ! CHECK: fir.result %[[VAL_50]] : !fir.array<40x!fir.char<1,?>>
833 ! CHECK: }
834 ! CHECK: fir.array_merge_store %[[VAL_19]], %[[VAL_51:.*]] to %[[VAL_9]] typeparams %[[VAL_8]] : !fir.array<40x!fir.char<1,?>>, !fir.array<40x!fir.char<1,?>>, !fir.ref<!fir.array<40x!fir.char<1,?>>>, i32
835 ! CHECK: return
836 ! CHECK: }
838 subroutine test19d(a,b,i,j)
839 character(i) a(40)
840 character(j) b(40)
841 a = b
842 end subroutine test19d
844 ! CHECK-LABEL: func @_QPtest19e(
845 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
846 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
847 ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<50x!fir.char<1,?>>>
848 ! CHECK: %[[VAL_4:.*]] = arith.constant 50 : index
849 ! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
850 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<50x!fir.char<1,?>>>
851 ! CHECK: %[[VAL_7:.*]] = arith.constant 50 : index
852 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
853 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.array<50x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<50x!fir.char<1,?>>
854 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
855 ! CHECK: %[[VAL_11:.*]] = fir.array_load %[[VAL_6]](%[[VAL_10]]) typeparams %[[VAL_5]]#1 : (!fir.ref<!fir.array<50x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<50x!fir.char<1,?>>
856 ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : index
857 ! CHECK: %[[VAL_13:.*]] = arith.constant 0 : index
858 ! CHECK: %[[VAL_14:.*]] = arith.subi %[[VAL_4]], %[[VAL_12]] : index
859 ! CHECK: %[[VAL_15:.*]] = fir.do_loop %[[VAL_16:.*]] = %[[VAL_13]] to %[[VAL_14]] step %[[VAL_12]] unordered iter_args(%[[VAL_17:.*]] = %[[VAL_9]]) -> (!fir.array<50x!fir.char<1,?>>) {
860 ! CHECK: %[[VAL_18:.*]] = fir.array_access %[[VAL_11]], %[[VAL_16]] typeparams %[[VAL_5]]#1 : (!fir.array<50x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
861 ! CHECK: %[[VAL_19:.*]] = fir.array_access %[[VAL_17]], %[[VAL_16]] typeparams %[[VAL_2]]#1 : (!fir.array<50x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
862 ! CHECK: %[[VAL_20:.*]] = arith.cmpi slt, %[[VAL_2]]#1, %[[VAL_5]]#1 : index
863 ! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_2]]#1, %[[VAL_5]]#1 : index
864 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : i64
865 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_21]] : (index) -> i64
866 ! CHECK: %[[VAL_24:.*]] = arith.muli %[[VAL_22]], %[[VAL_23]] : i64
867 ! CHECK: %[[VAL_25:.*]] = arith.constant false
868 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
869 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
870 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_26]], %[[VAL_27]], %[[VAL_24]], %[[VAL_25]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
871 ! CHECK: %[[VAL_28:.*]] = arith.constant 1 : index
872 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_2]]#1, %[[VAL_28]] : index
873 ! CHECK: %[[VAL_30:.*]] = arith.constant 32 : i8
874 ! CHECK: %[[VAL_31:.*]] = fir.undefined !fir.char<1>
875 ! CHECK: %[[VAL_32:.*]] = fir.insert_value %[[VAL_31]], %[[VAL_30]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
876 ! CHECK: %[[VAL_33:.*]] = arith.constant 1 : index
877 ! CHECK: fir.do_loop %[[VAL_34:.*]] = %[[VAL_21]] to %[[VAL_29]] step %[[VAL_33]] {
878 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_19]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
879 ! CHECK: %[[VAL_36:.*]] = fir.coordinate_of %[[VAL_35]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
880 ! CHECK: fir.store %[[VAL_32]] to %[[VAL_36]] : !fir.ref<!fir.char<1>>
881 ! CHECK: }
882 ! CHECK: %[[VAL_37:.*]] = fir.array_amend %[[VAL_17]], %[[VAL_19]] : (!fir.array<50x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<50x!fir.char<1,?>>
883 ! CHECK: fir.result %[[VAL_37]] : !fir.array<50x!fir.char<1,?>>
884 ! CHECK: }
885 ! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_38:.*]] to %[[VAL_3]] typeparams %[[VAL_2]]#1 : !fir.array<50x!fir.char<1,?>>, !fir.array<50x!fir.char<1,?>>, !fir.ref<!fir.array<50x!fir.char<1,?>>>, index
886 ! CHECK: return
887 ! CHECK: }
889 subroutine test19e(a,b)
890 character(*) a(50)
891 character(*) b(50)
892 a = b
893 end subroutine test19e
895 ! CHECK-LABEL: func @_QPtest19f(
896 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
897 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
898 ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<60x!fir.char<1,?>>>
899 ! CHECK: %[[VAL_4:.*]] = arith.constant 60 : index
900 ! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
901 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<60x!fir.char<1,?>>>
902 ! CHECK: %[[VAL_7:.*]] = arith.constant 60 : index
903 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
904 ! CHECK: %[[VAL_9:.*]] = fir.array_load %[[VAL_3]](%[[VAL_8]]) typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.array<60x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<60x!fir.char<1,?>>
905 ! CHECK: %[[VAL_10:.*]] = fir.address_of(@_QQcl.70726566697820) : !fir.ref<!fir.char<1,7>>
906 ! CHECK: %[[VAL_11:.*]] = arith.constant 7 : index
907 ! CHECK: %[[VAL_12:.*]] = fir.shape %[[VAL_7]] : (index) -> !fir.shape<1>
908 ! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_6]](%[[VAL_12]]) typeparams %[[VAL_5]]#1 : (!fir.ref<!fir.array<60x!fir.char<1,?>>>, !fir.shape<1>, index) -> !fir.array<60x!fir.char<1,?>>
909 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
910 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
911 ! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_4]], %[[VAL_14]] : index
912 ! CHECK: %[[VAL_17:.*]] = fir.do_loop %[[VAL_18:.*]] = %[[VAL_15]] to %[[VAL_16]] step %[[VAL_14]] unordered iter_args(%[[VAL_19:.*]] = %[[VAL_9]]) -> (!fir.array<60x!fir.char<1,?>>) {
913 ! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_13]], %[[VAL_18]] typeparams %[[VAL_5]]#1 : (!fir.array<60x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
914 ! CHECK: %[[VAL_21:.*]] = arith.addi %[[VAL_11]], %[[VAL_5]]#1 : index
915 ! CHECK: %[[VAL_22:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_21]] : index) {bindc_name = ".chrtmp"}
916 ! CHECK: %[[VAL_23:.*]] = arith.constant 1 : i64
917 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_11]] : (index) -> i64
918 ! CHECK: %[[VAL_25:.*]] = arith.muli %[[VAL_23]], %[[VAL_24]] : i64
919 ! CHECK: %[[VAL_26:.*]] = arith.constant false
920 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
921 ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_10]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<i8>
922 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_27]], %[[VAL_28]], %[[VAL_25]], %[[VAL_26]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
923 ! CHECK: %[[VAL_29:.*]] = arith.constant 1 : index
924 ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_21]], %[[VAL_29]] : index
925 ! CHECK: fir.do_loop %[[VAL_31:.*]] = %[[VAL_11]] to %[[VAL_30]] step %[[VAL_29]] {
926 ! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_31]], %[[VAL_11]] : index
927 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
928 ! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_32]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
929 ! CHECK: %[[VAL_35:.*]] = fir.load %[[VAL_34]] : !fir.ref<!fir.char<1>>
930 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
931 ! CHECK: %[[VAL_37:.*]] = fir.coordinate_of %[[VAL_36]], %[[VAL_31]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
932 ! CHECK: fir.store %[[VAL_35]] to %[[VAL_37]] : !fir.ref<!fir.char<1>>
933 ! CHECK: }
934 ! CHECK: %[[VAL_38:.*]] = fir.array_access %[[VAL_19]], %[[VAL_18]] typeparams %[[VAL_2]]#1 : (!fir.array<60x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
935 ! CHECK: %[[VAL_39:.*]] = arith.cmpi slt, %[[VAL_2]]#1, %[[VAL_21]] : index
936 ! CHECK: %[[VAL_40:.*]] = arith.select %[[VAL_39]], %[[VAL_2]]#1, %[[VAL_21]] : index
937 ! CHECK: %[[VAL_41:.*]] = arith.constant 1 : i64
938 ! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_40]] : (index) -> i64
939 ! CHECK: %[[VAL_43:.*]] = arith.muli %[[VAL_41]], %[[VAL_42]] : i64
940 ! CHECK: %[[VAL_44:.*]] = arith.constant false
941 ! CHECK: %[[VAL_45:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
942 ! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_22]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
943 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_45]], %[[VAL_46]], %[[VAL_43]], %[[VAL_44]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
944 ! CHECK: %[[VAL_47:.*]] = arith.constant 1 : index
945 ! CHECK: %[[VAL_48:.*]] = arith.subi %[[VAL_2]]#1, %[[VAL_47]] : index
946 ! CHECK: %[[VAL_49:.*]] = arith.constant 32 : i8
947 ! CHECK: %[[VAL_50:.*]] = fir.undefined !fir.char<1>
948 ! CHECK: %[[VAL_51:.*]] = fir.insert_value %[[VAL_50]], %[[VAL_49]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
949 ! CHECK: %[[VAL_52:.*]] = arith.constant 1 : index
950 ! CHECK: fir.do_loop %[[VAL_53:.*]] = %[[VAL_40]] to %[[VAL_48]] step %[[VAL_52]] {
951 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_38]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
952 ! CHECK: %[[VAL_55:.*]] = fir.coordinate_of %[[VAL_54]], %[[VAL_53]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
953 ! CHECK: fir.store %[[VAL_51]] to %[[VAL_55]] : !fir.ref<!fir.char<1>>
954 ! CHECK: }
955 ! CHECK: %[[VAL_56:.*]] = fir.array_amend %[[VAL_19]], %[[VAL_38]] : (!fir.array<60x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<60x!fir.char<1,?>>
956 ! CHECK: fir.result %[[VAL_56]] : !fir.array<60x!fir.char<1,?>>
957 ! CHECK: }
958 ! CHECK: fir.array_merge_store %[[VAL_9]], %[[VAL_57:.*]] to %[[VAL_3]] typeparams %[[VAL_2]]#1 : !fir.array<60x!fir.char<1,?>>, !fir.array<60x!fir.char<1,?>>, !fir.ref<!fir.array<60x!fir.char<1,?>>>, index
959 ! CHECK: return
960 ! CHECK: }
962 subroutine test19f(a,b)
963 character(*) a(60)
964 character(*) b(60)
965 a = "prefix " // b
966 end subroutine test19f
968 ! CHECK-LABEL: func @_QPtest19g(
969 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<4>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<2>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}) {
970 ! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<2>) -> (!fir.ref<!fir.char<2,?>>, index)
971 ! CHECK: %[[VAL_4:.*]] = arith.constant 13 : index
972 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<2,?>>) -> !fir.ref<!fir.array<140x!fir.char<2,13>>>
973 ! CHECK: %[[VAL_6:.*]] = arith.constant 140 : index
974 ! CHECK: %[[VAL_7:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<4>) -> (!fir.ref<!fir.char<4,?>>, index)
975 ! CHECK: %[[VAL_8:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
976 ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : i32
977 ! CHECK: %[[VAL_10:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_9]] : i32
978 ! CHECK: %[[VAL_11:.*]] = arith.select %[[VAL_10]], %[[VAL_8]], %[[VAL_9]] : i32
979 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_7]]#0 : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<70x!fir.char<4,?>>>
980 ! CHECK: %[[VAL_13:.*]] = arith.constant 70 : index
981 ! CHECK: %[[VAL_14:.*]] = fir.shape %[[VAL_13]] : (index) -> !fir.shape<1>
982 ! CHECK: %[[VAL_15:.*]] = fir.array_load %[[VAL_12]](%[[VAL_14]]) typeparams %[[VAL_11]] : (!fir.ref<!fir.array<70x!fir.char<4,?>>>, !fir.shape<1>, i32) -> !fir.array<70x!fir.char<4,?>>
983 ! CHECK: %[[VAL_16:.*]] = arith.constant 1 : i64
984 ! CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
985 ! CHECK: %[[VAL_18:.*]] = arith.constant 2 : i64
986 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
987 ! CHECK: %[[VAL_20:.*]] = arith.constant 140 : i64
988 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i64) -> index
989 ! CHECK: %[[VAL_22:.*]] = fir.shape %[[VAL_6]] : (index) -> !fir.shape<1>
990 ! CHECK: %[[VAL_23:.*]] = fir.slice %[[VAL_17]], %[[VAL_21]], %[[VAL_19]] : (index, index, index) -> !fir.slice<1>
991 ! CHECK: %[[VAL_24:.*]] = fir.array_load %[[VAL_5]](%[[VAL_22]]) {{\[}}%[[VAL_23]]] : (!fir.ref<!fir.array<140x!fir.char<2,13>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<140x!fir.char<2,13>>
992 ! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
993 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (i32) -> i64
994 ! CHECK: %[[char_temp:.*]] = fir.alloca !fir.char<4,?>(%16 : i64) {bindc_name = ".chrtmp"}
995 ! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
996 ! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
997 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_13]], %[[VAL_27]] : index
998 ! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_15]]) -> (!fir.array<70x!fir.char<4,?>>) {
999 ! CHECK: %[[VAL_33:.*]] = fir.array_access %[[VAL_24]], %[[VAL_31]] : (!fir.array<140x!fir.char<2,13>>, index) -> !fir.ref<!fir.char<2,13>>
1000 ! CHECK: %[[VAL_34:.*]] = fir.alloca !fir.char<4,?>(%[[VAL_4]] : index)
1001 ! CHECK: %[[VAL_46:.*]] = fir.array_access %[[VAL_32]], %[[VAL_31]] typeparams %[[VAL_11]] : (!fir.array<70x!fir.char<4,?>>, index, i32) -> !fir.ref<!fir.char<4,?>>
1002 ! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_11]] : (i32) -> index
1003 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_26]] : (i64) -> index
1004 ! CHECK: %[[VAL_49:.*]] = arith.cmpi slt, %[[VAL_47]], %[[VAL_48]] : index
1005 ! CHECK: %[[VAL_50:.*]] = arith.select %[[VAL_49]], %[[VAL_47]], %[[VAL_48]] : index
1006 ! CHECK: %[[VAL_51:.*]] = arith.constant 4 : i64
1007 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_50]] : (index) -> i64
1008 ! CHECK: %[[VAL_53:.*]] = arith.muli %[[VAL_51]], %[[VAL_52]] : i64
1009 ! CHECK: %[[VAL_54:.*]] = arith.constant false
1010 ! CHECK: %[[VAL_55:.*]] = fir.convert %[[VAL_46]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<i8>
1011 ! CHECK: %[[VAL_56:.*]] = fir.convert %[[char_temp]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<i8>
1012 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_55]], %[[VAL_56]], %[[VAL_53]], %[[VAL_54]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
1013 ! CHECK: %[[VAL_57:.*]] = arith.constant 1 : i32
1014 ! CHECK: %[[VAL_58:.*]] = arith.subi %[[VAL_11]], %[[VAL_57]] : i32
1015 ! CHECK: %[[VAL_59:.*]] = arith.constant 32 : i32
1016 ! CHECK: %[[VAL_60:.*]] = fir.undefined !fir.char<4>
1017 ! CHECK: %[[VAL_61:.*]] = fir.insert_value %[[VAL_60]], %[[VAL_59]], [0 : index] : (!fir.char<4>, i32) -> !fir.char<4>
1018 ! CHECK: %[[VAL_62:.*]] = arith.constant 1 : index
1019 ! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_58]] : (i32) -> index
1020 ! CHECK: fir.do_loop %[[VAL_64:.*]] = %[[VAL_50]] to %[[VAL_63]] step %[[VAL_62]] {
1021 ! CHECK: %[[VAL_65:.*]] = fir.convert %[[VAL_46]] : (!fir.ref<!fir.char<4,?>>) -> !fir.ref<!fir.array<?x!fir.char<4>>>
1022 ! CHECK: %[[VAL_66:.*]] = fir.coordinate_of %[[VAL_65]], %[[VAL_64]] : (!fir.ref<!fir.array<?x!fir.char<4>>>, index) -> !fir.ref<!fir.char<4>>
1023 ! CHECK: fir.store %[[VAL_61]] to %[[VAL_66]] : !fir.ref<!fir.char<4>>
1024 ! CHECK: }
1025 ! CHECK: %[[VAL_67:.*]] = fir.array_amend %[[VAL_32]], %[[VAL_46]] : (!fir.array<70x!fir.char<4,?>>, !fir.ref<!fir.char<4,?>>) -> !fir.array<70x!fir.char<4,?>>
1026 ! CHECK: fir.result %[[VAL_67]] : !fir.array<70x!fir.char<4,?>>
1027 ! CHECK: }
1028 ! CHECK: fir.array_merge_store %[[VAL_15]], %[[VAL_68:.*]] to %[[VAL_12]] typeparams %[[VAL_11]] : !fir.array<70x!fir.char<4,?>>, !fir.array<70x!fir.char<4,?>>, !fir.ref<!fir.array<70x!fir.char<4,?>>>, i32
1029 ! CHECK: return
1030 ! CHECK: }
1032 subroutine test19g(a,b,i)
1033 character(kind=4,len=i) a(70)
1034 character(kind=2,len=13) b(140)
1035 a = b(1:140:2)
1036 end subroutine test19g
1038 ! CHECK-LABEL: func @_QPtest19h(
1039 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_2:.*]]: !fir.ref<i32>{{.*}}, %[[VAL_3:.*]]: !fir.ref<i32>{{.*}}) {
1040 ! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
1041 ! CHECK: %[[VAL_5:.*]] = fir.load %[[VAL_2]] : !fir.ref<i32>
1042 ! CHECK: %[[VAL_6:.*]] = arith.constant 0 : i32
1043 ! CHECK: %[[VAL_7:.*]] = arith.cmpi sgt, %[[VAL_5]], %[[VAL_6]] : i32
1044 ! CHECK: %[[VAL_8:.*]] = arith.select %[[VAL_7]], %[[VAL_5]], %[[VAL_6]] : i32
1045 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<70x!fir.char<1,?>>>
1046 ! CHECK: %[[VAL_10:.*]] = arith.constant 70 : index
1047 ! CHECK: %[[VAL_11:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
1048 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1,?>>>
1049 ! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_3]] : !fir.ref<i32>
1050 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (i32) -> i64
1051 ! CHECK: %[[VAL_15A:.*]] = fir.convert %[[VAL_14]] : (i64) -> index
1052 ! CHECK: %[[C0:.*]] = arith.constant 0 : index
1053 ! CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[VAL_15A]], %[[C0]] : index
1054 ! CHECK: %[[VAL_15:.*]] = arith.select %[[CMP]], %[[VAL_15A]], %[[C0]] : index
1055 ! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_10]] : (index) -> !fir.shape<1>
1056 ! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_9]](%[[VAL_16]]) typeparams %[[VAL_8]] : (!fir.ref<!fir.array<70x!fir.char<1,?>>>, !fir.shape<1>, i32) -> !fir.array<70x!fir.char<1,?>>
1057 ! CHECK: %[[VAL_18:.*]] = arith.constant 1 : i64
1058 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
1059 ! CHECK: %[[VAL_20:.*]] = arith.constant 2 : i64
1060 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (i64) -> index
1061 ! CHECK: %[[VAL_22:.*]] = arith.constant 140 : i64
1062 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
1063 ! CHECK: %[[VAL_24:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
1064 ! CHECK: %[[VAL_25:.*]] = fir.slice %[[VAL_19]], %[[VAL_23]], %[[VAL_21]] : (index, index, index) -> !fir.slice<1>
1065 ! CHECK: %[[VAL_26:.*]] = fir.array_load %[[VAL_12]](%[[VAL_24]]) {{\[}}%[[VAL_25]]] typeparams %[[VAL_11]]#1 : (!fir.ref<!fir.array<?x!fir.char<1,?>>>, !fir.shape<1>, !fir.slice<1>, index) -> !fir.array<?x!fir.char<1,?>>
1066 ! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
1067 ! CHECK: %[[VAL_28:.*]] = arith.constant 0 : index
1068 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_10]], %[[VAL_27]] : index
1069 ! CHECK: %[[VAL_30:.*]] = fir.do_loop %[[VAL_31:.*]] = %[[VAL_28]] to %[[VAL_29]] step %[[VAL_27]] unordered iter_args(%[[VAL_32:.*]] = %[[VAL_17]]) -> (!fir.array<70x!fir.char<1,?>>) {
1070 ! CHECK: %[[VAL_33:.*]] = fir.array_access %[[VAL_26]], %[[VAL_31]] typeparams %[[VAL_11]]#1 : (!fir.array<?x!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>
1071 ! CHECK: %[[VAL_34:.*]] = fir.array_access %[[VAL_32]], %[[VAL_31]] typeparams %[[VAL_8]] : (!fir.array<70x!fir.char<1,?>>, index, i32) -> !fir.ref<!fir.char<1,?>>
1072 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_8]] : (i32) -> index
1073 ! CHECK: %[[VAL_36:.*]] = arith.cmpi slt, %[[VAL_35]], %[[VAL_11]]#1 : index
1074 ! CHECK: %[[VAL_37:.*]] = arith.select %[[VAL_36]], %[[VAL_35]], %[[VAL_11]]#1 : index
1075 ! CHECK: %[[VAL_38:.*]] = arith.constant 1 : i64
1076 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_37]] : (index) -> i64
1077 ! CHECK: %[[VAL_40:.*]] = arith.muli %[[VAL_38]], %[[VAL_39]] : i64
1078 ! CHECK: %[[VAL_41:.*]] = arith.constant false
1079 ! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
1080 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_33]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
1081 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_42]], %[[VAL_43]], %[[VAL_40]], %[[VAL_41]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
1082 ! CHECK: %[[VAL_44:.*]] = arith.constant 1 : i32
1083 ! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_8]], %[[VAL_44]] : i32
1084 ! CHECK: %[[VAL_46:.*]] = arith.constant 32 : i8
1085 ! CHECK: %[[VAL_47:.*]] = fir.undefined !fir.char<1>
1086 ! CHECK: %[[VAL_48:.*]] = fir.insert_value %[[VAL_47]], %[[VAL_46]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
1087 ! CHECK: %[[VAL_49:.*]] = arith.constant 1 : index
1088 ! CHECK: %[[VAL_50:.*]] = fir.convert %[[VAL_45]] : (i32) -> index
1089 ! CHECK: fir.do_loop %[[VAL_51:.*]] = %[[VAL_37]] to %[[VAL_50]] step %[[VAL_49]] {
1090 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
1091 ! CHECK: %[[VAL_53:.*]] = fir.coordinate_of %[[VAL_52]], %[[VAL_51]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
1092 ! CHECK: fir.store %[[VAL_48]] to %[[VAL_53]] : !fir.ref<!fir.char<1>>
1093 ! CHECK: }
1094 ! CHECK: %[[VAL_54:.*]] = fir.array_amend %[[VAL_32]], %[[VAL_34]] : (!fir.array<70x!fir.char<1,?>>, !fir.ref<!fir.char<1,?>>) -> !fir.array<70x!fir.char<1,?>>
1095 ! CHECK: fir.result %[[VAL_54]] : !fir.array<70x!fir.char<1,?>>
1096 ! CHECK: }
1097 ! CHECK: fir.array_merge_store %[[VAL_17]], %[[VAL_55:.*]] to %[[VAL_9]] typeparams %[[VAL_8]] : !fir.array<70x!fir.char<1,?>>, !fir.array<70x!fir.char<1,?>>, !fir.ref<!fir.array<70x!fir.char<1,?>>>, i32
1098 ! CHECK: return
1099 ! CHECK: }
1101 subroutine test19h(a,b,i,j)
1102 character(i) a(70)
1103 character(*) b(j)
1104 a = b(1:140:2)
1105 end subroutine test19h
1107 ! CHECK-LABEL: func @_QPtest_elemental_character_intrinsic(
1108 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
1109 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
1110 ! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
1111 ! CHECK: %[[VAL_4:.*]] = arith.constant 10 : index
1112 ! CHECK: %[[VAL_5:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
1113 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
1114 ! CHECK: %[[VAL_7:.*]] = arith.constant 2 : index
1115 ! CHECK: %[[VAL_8:.*]] = arith.constant 10 : index
1116 ! CHECK: %[[VAL_9:.*]] = arith.constant -1 : i32
1117 ! CHECK: %[[VAL_10:.*]] = fir.address_of(@_QQcl.{{.*}}) : !fir.ref<!fir.char<1,
1118 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref<!fir.char<1,{{.*}}>>) -> !fir.ref<i8>
1119 ! CHECK: %[[VAL_12:.*]] = arith.constant {{.*}} : i32
1120 ! CHECK: %[[VAL_13:.*]] = fir.call @_FortranAioBeginExternalListOutput(%[[VAL_9]], %[[VAL_11]], %[[VAL_12]]) {{.*}}: (i32, !fir.ref<i8>, i32) -> !fir.ref<i8>
1121 ! CHECK: %[[VAL_15:.*]] = arith.constant 10 : index
1122 ! CHECK: %[[VAL_16:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
1123 ! CHECK: %[[VAL_17:.*]] = fir.shape_shift %[[VAL_7]], %[[VAL_8]] : (index, index) -> !fir.shapeshift<1>
1124 ! CHECK: %[[VAL_18:.*]] = fir.allocmem !fir.array<10xi32>
1125 ! CHECK: %[[VAL_19:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
1126 ! CHECK: %[[VAL_20:.*]] = fir.array_load %[[VAL_18]](%[[VAL_19]]) : (!fir.heap<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.array<10xi32>
1127 ! CHECK: %[[VAL_21:.*]] = arith.constant 1 : index
1128 ! CHECK: %[[VAL_22:.*]] = arith.constant 0 : index
1129 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_15]], %[[VAL_21]] : index
1130 ! 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<10xi32>) {
1131 ! CHECK: %[[VAL_27:.*]] = arith.constant 1 : index
1132 ! CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_25]], %[[VAL_27]] : index
1133 ! CHECK: %[[VAL_29:.*]] = fir.array_coor %[[VAL_3]](%[[VAL_16]]) %[[VAL_28]] typeparams %[[VAL_2]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
1134 ! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_25]], %[[VAL_7]] : index
1135 ! CHECK: %[[VAL_31:.*]] = fir.array_coor %[[VAL_6]](%[[VAL_17]]) %[[VAL_30]] typeparams %[[VAL_5]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shapeshift<1>, index, index) -> !fir.ref<!fir.char<1,?>>
1136 ! CHECK: %[[VAL_32:.*]] = arith.constant false
1137 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
1138 ! CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
1139 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_31]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
1140 ! CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_5]]#1 : (index) -> i64
1141 ! CHECK: %[[VAL_37:.*]] = fir.call @_FortranAScan1(%[[VAL_33]], %[[VAL_34]], %[[VAL_35]], %[[VAL_36]], %[[VAL_32]]) {{.*}}: (!fir.ref<i8>, i64, !fir.ref<i8>, i64, i1) -> i64
1142 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_37]] : (i64) -> i32
1143 ! CHECK: %[[VAL_39:.*]] = fir.array_update %[[VAL_26]], %[[VAL_38]], %[[VAL_25]] : (!fir.array<10xi32>, i32, index) -> !fir.array<10xi32>
1144 ! CHECK: fir.result %[[VAL_39]] : !fir.array<10xi32>
1145 ! CHECK: }
1146 ! CHECK: fir.array_merge_store %[[VAL_20]], %[[VAL_40:.*]] to %[[VAL_18]] : !fir.array<10xi32>, !fir.array<10xi32>, !fir.heap<!fir.array<10xi32>>
1147 ! CHECK: %[[VAL_41:.*]] = fir.shape %[[VAL_15]] : (index) -> !fir.shape<1>
1148 ! CHECK: %[[VAL_42:.*]] = fir.embox %[[VAL_18]](%[[VAL_41]]) : (!fir.heap<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xi32>>
1149 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_42]] : (!fir.box<!fir.array<10xi32>>) -> !fir.box<none>
1150 ! CHECK: %[[VAL_44:.*]] = fir.call @_FortranAioOutputDescriptor(%[[VAL_13]], %[[VAL_43]]) {{.*}}: (!fir.ref<i8>, !fir.box<none>) -> i1
1151 ! CHECK: fir.freemem %[[VAL_18]] : !fir.heap<!fir.array<10xi32>>
1152 ! CHECK: %[[VAL_45:.*]] = fir.call @_FortranAioEndIoStatement(%[[VAL_13]]) {{.*}}: (!fir.ref<i8>) -> i32
1153 ! CHECK: return
1154 ! CHECK: }
1156 subroutine test_elemental_character_intrinsic(c1, c2)
1157 character(*) :: c1(10), c2(2:11)
1158 print *, scan(c1, c2)
1159 end subroutine
1161 ! CHECK: func private @_QPbar(