Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / character-substrings.f90
blob9015af1258b8eeb09c5889aa1e6859b199ac66b5
1 ! Test character substring lowering
2 ! RUN: bbc %s -o - -emit-fir | FileCheck %s
4 ! Test substring lower where the parent is a scalar-char-literal-constant
5 ! CHECK-LABEL: func @_QPscalar_substring_embox(
6 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<i64>{{.*}}, %[[VAL_1:.*]]: !fir.ref<i64>{{.*}}) {
7 subroutine scalar_substring_embox(i, j)
8 ! CHECK: %[[VAL_2:.*]] = fir.address_of(@_QQcl.{{.*}}) : !fir.ref<!fir.char<1,18>>
9 ! CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_0]] : !fir.ref<i64>
10 ! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_1]] : !fir.ref<i64>
11 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]] : (i64) -> index
12 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
13 ! CHECK: %[[VAL_7:.*]] = arith.constant 1 : index
14 ! CHECK: %[[VAL_8:.*]] = arith.subi %[[VAL_5]], %[[VAL_7]] : index
15 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_2]] : (!fir.ref<!fir.char<1,18>>) -> !fir.ref<!fir.array<18x!fir.char<1>>>
16 ! CHECK: %[[VAL_10:.*]] = fir.coordinate_of %[[VAL_9]], %[[VAL_8]] : (!fir.ref<!fir.array<18x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
17 ! CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_10]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
18 ! CHECK: %[[VAL_12:.*]] = arith.subi %[[VAL_6]], %[[VAL_5]] : index
19 ! CHECK: %[[VAL_13:.*]] = arith.addi %[[VAL_12]], %[[VAL_7]] : index
20 ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : index
21 ! CHECK: %[[VAL_15:.*]] = arith.cmpi slt, %[[VAL_13]], %[[VAL_14]] : index
22 ! CHECK: %[[VAL_16:.*]] = arith.select %[[VAL_15]], %[[VAL_14]], %[[VAL_13]] : index
23 ! CHECK: %[[VAL_17:.*]] = fir.emboxchar %[[VAL_11]], %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
24 ! CHECK: fir.call @_QPbar(%[[VAL_17]]) {{.*}}: (!fir.boxchar<1>) -> ()
25 integer(8) :: i, j
26 call bar("abcHello World!dfg"(i:j))
27 ! CHECK: return
28 ! CHECK: }
29 end subroutine scalar_substring_embox
31 ! CHECK-LABEL: func @_QParray_substring_embox(
32 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}) {
33 ! CHECK: %[[VAL_1:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
34 ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<4x!fir.char<1,7>>>
35 ! CHECK: %[[VAL_3:.*]] = arith.constant 4 : index
36 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
37 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
38 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
39 ! CHECK: %[[VAL_7:.*]] = arith.addi %[[VAL_4]], %[[VAL_3]] : index
40 ! CHECK: %[[VAL_8:.*]] = arith.subi %[[VAL_7]], %[[VAL_4]] : index
41 ! CHECK: %[[VAL_9:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
42 ! CHECK: %[[VAL_10:.*]] = arith.constant 5 : i64
43 ! CHECK: %[[VAL_11:.*]] = arith.constant 5 : i64
44 ! CHECK: %[[VAL_12:.*]] = arith.constant 1 : i64
45 ! CHECK: %[[VAL_13:.*]] = arith.subi %[[VAL_10]], %[[VAL_12]] : i64
46 ! CHECK: %[[VAL_14:.*]] = arith.constant 0 : i64
47 ! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_11]], %[[VAL_13]] : i64
48 ! CHECK: %[[VAL_16:.*]] = arith.cmpi sgt, %[[VAL_15]], %[[VAL_14]] : i64
49 ! CHECK: %[[VAL_17:.*]] = arith.select %[[VAL_16]], %[[VAL_15]], %[[VAL_14]] : i64
50 ! CHECK: %[[VAL_18:.*]] = fir.slice %[[VAL_4]], %[[VAL_8]], %[[VAL_6]] substr %[[VAL_13]], %[[VAL_17]] : (index, index, index, i64, i64) -> !fir.slice<1>
51 ! CHECK: %[[VAL_19:.*]] = fir.embox %[[VAL_2]](%[[VAL_9]]) {{\[}}%[[VAL_18]]] : (!fir.ref<!fir.array<4x!fir.char<1,7>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<?x!fir.char<1,?>>>
52 ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_19]] : (!fir.box<!fir.array<?x!fir.char<1,?>>>) -> !fir.box<!fir.array<?x!fir.char<1>>>
53 ! CHECK: fir.call @_QPs(%[[VAL_20]]) {{.*}}: (!fir.box<!fir.array<?x!fir.char<1>>>) -> ()
54 ! CHECK: return
55 ! CHECK: }
57 subroutine array_substring_embox(arr)
58 interface
59 subroutine s(a)
60 character(1) :: a(:)
61 end subroutine s
62 end interface
64 character(7) arr(4)
66 call s(arr(:)(5:5))
67 end subroutine array_substring_embox
69 ! CHECK-LABEL: func @_QPsubstring_assignment(
70 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}, %[[VAL_1:.*]]: !fir.boxchar<1>{{.*}}) {
71 subroutine substring_assignment(a,b)
72 ! CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
73 ! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
74 ! CHECK: %[[VAL_4:.*]] = arith.constant 3 : i64
75 ! CHECK: %[[VAL_5:.*]] = arith.constant 4 : i64
76 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_4]] : (i64) -> index
77 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
78 ! CHECK: %[[VAL_8:.*]] = arith.constant 1 : index
79 ! CHECK: %[[VAL_9:.*]] = arith.subi %[[VAL_6]], %[[VAL_8]] : index
80 ! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
81 ! CHECK: %[[VAL_11:.*]] = fir.coordinate_of %[[VAL_10]], %[[VAL_9]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
82 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
83 ! CHECK: %[[VAL_13:.*]] = arith.subi %[[VAL_7]], %[[VAL_6]] : index
84 ! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_13]], %[[VAL_8]] : index
85 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
86 ! CHECK: %[[VAL_16:.*]] = arith.cmpi slt, %[[VAL_14]], %[[VAL_15]] : index
87 ! CHECK: %[[VAL_17:.*]] = arith.select %[[VAL_16]], %[[VAL_15]], %[[VAL_14]] : index
88 ! CHECK: %[[VAL_18:.*]] = arith.constant 1 : i64
89 ! CHECK: %[[VAL_19:.*]] = arith.constant 2 : i64
90 ! CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_18]] : (i64) -> index
91 ! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_19]] : (i64) -> index
92 ! CHECK: %[[VAL_22:.*]] = arith.constant 1 : index
93 ! CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_20]], %[[VAL_22]] : index
94 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
95 ! CHECK: %[[VAL_25:.*]] = fir.coordinate_of %[[VAL_24]], %[[VAL_23]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
96 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_25]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
97 ! CHECK: %[[VAL_27:.*]] = arith.subi %[[VAL_21]], %[[VAL_20]] : index
98 ! CHECK: %[[VAL_28:.*]] = arith.addi %[[VAL_27]], %[[VAL_22]] : index
99 ! CHECK: %[[VAL_29:.*]] = arith.constant 0 : index
100 ! CHECK: %[[VAL_30:.*]] = arith.cmpi slt, %[[VAL_28]], %[[VAL_29]] : index
101 ! CHECK: %[[VAL_31:.*]] = arith.select %[[VAL_30]], %[[VAL_29]], %[[VAL_28]] : index
102 ! CHECK: %[[VAL_32:.*]] = arith.cmpi slt, %[[VAL_31]], %[[VAL_17]] : index
103 ! CHECK: %[[VAL_33:.*]] = arith.select %[[VAL_32]], %[[VAL_31]], %[[VAL_17]] : index
104 ! CHECK: %[[VAL_34:.*]] = arith.constant 1 : i64
105 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_33]] : (index) -> i64
106 ! CHECK: %[[VAL_36:.*]] = arith.muli %[[VAL_34]], %[[VAL_35]] : i64
107 ! CHECK: %[[VAL_37:.*]] = arith.constant false
108 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
109 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_12]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
110 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_38]], %[[VAL_39]], %[[VAL_36]], %[[VAL_37]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
111 ! CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
112 ! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_31]], %[[VAL_40]] : index
113 ! CHECK: %[[VAL_42:.*]] = arith.constant 32 : i8
114 ! CHECK: %[[VAL_43:.*]] = fir.undefined !fir.char<1>
115 ! CHECK: %[[VAL_44:.*]] = fir.insert_value %[[VAL_43]], %[[VAL_42]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
116 ! CHECK: %[[VAL_45:.*]] = arith.constant 1 : index
117 ! CHECK: fir.do_loop %[[VAL_46:.*]] = %[[VAL_33]] to %[[VAL_41]] step %[[VAL_45]] {
118 ! CHECK: %[[VAL_47:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
119 ! CHECK: %[[VAL_48:.*]] = fir.coordinate_of %[[VAL_47]], %[[VAL_46]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
120 ! CHECK: fir.store %[[VAL_44]] to %[[VAL_48]] : !fir.ref<!fir.char<1>>
121 ! CHECK: }
123 character(4) :: a, b
124 a(1:2) = b(3:4)
125 ! CHECK: return
126 ! CHECK: }
127 end subroutine substring_assignment
129 ! CHECK-LABEL: func @_QParray_substring_assignment(
130 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}) {
131 ! CHECK: %[[VAL_1:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
132 ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<6x!fir.char<1,5>>>
133 ! CHECK: %[[VAL_3:.*]] = arith.constant 6 : index
134 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
135 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
136 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
137 ! CHECK: %[[VAL_7:.*]] = arith.addi %[[VAL_4]], %[[VAL_3]] : index
138 ! CHECK: %[[VAL_8:.*]] = arith.subi %[[VAL_7]], %[[VAL_4]] : index
139 ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
140 ! CHECK: %[[VAL_10:.*]] = arith.subi %[[VAL_8]], %[[VAL_4]] : index
141 ! CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_10]], %[[VAL_6]] : index
142 ! CHECK: %[[VAL_12:.*]] = arith.divsi %[[VAL_11]], %[[VAL_6]] : index
143 ! CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_9]] : index
144 ! CHECK: %[[VAL_14:.*]] = arith.select %[[VAL_13]], %[[VAL_12]], %[[VAL_9]] : index
145 ! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
146 ! CHECK: %[[VAL_16:.*]] = fir.slice %[[VAL_4]], %[[VAL_8]], %[[VAL_6]] : (index, index, index) -> !fir.slice<1>
147 ! CHECK: %[[VAL_17:.*]] = fir.array_load %[[VAL_2]](%[[VAL_15]]) {{\[}}%[[VAL_16]]] : (!fir.ref<!fir.array<6x!fir.char<1,5>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<6x!fir.char<1,5>>
148 ! CHECK: %[[VAL_18:.*]] = fir.address_of(@_QQcl.424144) : !fir.ref<!fir.char<1,3>>
149 ! CHECK: %[[VAL_19:.*]] = arith.constant 3 : index
150 ! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
151 ! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
152 ! CHECK: %[[VAL_22:.*]] = arith.subi %[[VAL_14]], %[[VAL_20]] : index
153 ! CHECK: %[[VAL_23:.*]] = fir.do_loop %[[VAL_24:.*]] = %[[VAL_21]] to %[[VAL_22]] step %[[VAL_20]] unordered iter_args(%[[VAL_25:.*]] = %[[VAL_17]]) -> (!fir.array<6x!fir.char<1,5>>) {
154 ! CHECK: %[[VAL_26:.*]] = fir.array_access %[[VAL_25]], %[[VAL_24]] : (!fir.array<6x!fir.char<1,5>>, index) -> !fir.ref<!fir.char<1,5>>
155 ! CHECK: %[[VAL_27:.*]] = arith.constant 3 : i64
156 ! CHECK: %[[VAL_28:.*]] = arith.constant 5 : i64
157 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_27]] : (i64) -> index
158 ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_28]] : (i64) -> index
159 ! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
160 ! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_29]], %[[VAL_31]] : index
161 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<!fir.array<5x!fir.char<1>>>
162 ! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_32]] : (!fir.ref<!fir.array<5x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
163 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
164 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_30]], %[[VAL_29]] : index
165 ! CHECK: %[[VAL_37:.*]] = arith.addi %[[VAL_36]], %[[VAL_31]] : index
166 ! CHECK: %[[VAL_38:.*]] = arith.constant 0 : index
167 ! CHECK: %[[VAL_39:.*]] = arith.cmpi slt, %[[VAL_37]], %[[VAL_38]] : index
168 ! CHECK: %[[VAL_40:.*]] = arith.select %[[VAL_39]], %[[VAL_38]], %[[VAL_37]] : index
169 ! CHECK: %[[VAL_41:.*]] = arith.constant 0 : index
170 ! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
171 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_40]] : (index) -> index
172 ! CHECK: %[[VAL_44:.*]] = arith.subi %[[VAL_43]], %[[VAL_42]] : index
173 ! CHECK: fir.do_loop %[[VAL_45:.*]] = %[[VAL_41]] to %[[VAL_44]] step %[[VAL_42]] {
174 ! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_19]] : (index) -> index
175 ! CHECK: %[[VAL_47:.*]] = arith.cmpi slt, %[[VAL_45]], %[[VAL_46]] : index
176 ! CHECK: fir.if %[[VAL_47]] {
177 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
178 ! CHECK: %[[VAL_49:.*]] = fir.coordinate_of %[[VAL_48]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
179 ! CHECK: %[[VAL_50:.*]] = fir.load %[[VAL_49]] : !fir.ref<!fir.char<1>>
180 ! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
181 ! CHECK: %[[VAL_52:.*]] = fir.coordinate_of %[[VAL_51]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
182 ! CHECK: fir.store %[[VAL_50]] to %[[VAL_52]] : !fir.ref<!fir.char<1>>
183 ! CHECK: } else {
184 ! CHECK: %[[VAL_53:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
185 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
186 ! CHECK: %[[VAL_55:.*]] = fir.coordinate_of %[[VAL_54]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
187 ! CHECK: fir.store %[[VAL_53]] to %[[VAL_55]] : !fir.ref<!fir.char<1>>
188 ! CHECK: }
189 ! CHECK: }
190 ! CHECK: %[[VAL_56:.*]] = arith.cmpi slt, %[[VAL_40]], %[[VAL_19]] : index
191 ! CHECK: %[[VAL_57:.*]] = arith.select %[[VAL_56]], %[[VAL_40]], %[[VAL_19]] : index
192 ! CHECK: %[[VAL_58:.*]] = arith.constant 1 : i64
193 ! CHECK: %[[VAL_59:.*]] = fir.convert %[[VAL_57]] : (index) -> i64
194 ! CHECK: %[[VAL_60:.*]] = arith.muli %[[VAL_58]], %[[VAL_59]] : i64
195 ! CHECK: %[[VAL_61:.*]] = arith.constant false
196 ! CHECK: %[[VAL_62:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
197 ! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
198 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_62]], %[[VAL_63]], %[[VAL_60]], %[[VAL_61]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
199 ! CHECK: %[[VAL_64:.*]] = arith.constant 1 : index
200 ! CHECK: %[[VAL_65:.*]] = arith.subi %[[VAL_40]], %[[VAL_64]] : index
201 ! CHECK: %[[VAL_66:.*]] = arith.constant 32 : i8
202 ! CHECK: %[[VAL_67:.*]] = fir.undefined !fir.char<1>
203 ! CHECK: %[[VAL_68:.*]] = fir.insert_value %[[VAL_67]], %[[VAL_66]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
204 ! CHECK: %[[VAL_69:.*]] = arith.constant 1 : index
205 ! CHECK: fir.do_loop %[[VAL_70:.*]] = %[[VAL_57]] to %[[VAL_65]] step %[[VAL_69]] {
206 ! CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
207 ! CHECK: %[[VAL_72:.*]] = fir.coordinate_of %[[VAL_71]], %[[VAL_70]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
208 ! CHECK: fir.store %[[VAL_68]] to %[[VAL_72]] : !fir.ref<!fir.char<1>>
209 ! CHECK: }
210 ! CHECK: %[[VAL_73:.*]] = fir.array_amend %[[VAL_25]], %[[VAL_26]] : (!fir.array<6x!fir.char<1,5>>, !fir.ref<!fir.char<1,5>>) -> !fir.array<6x!fir.char<1,5>>
211 ! CHECK: fir.result %[[VAL_73]] : !fir.array<6x!fir.char<1,5>>
212 ! CHECK: }
213 ! CHECK: fir.array_merge_store %[[VAL_17]], %[[VAL_74:.*]] to %[[VAL_2]]{{\[}}%[[VAL_16]]] : !fir.array<6x!fir.char<1,5>>, !fir.array<6x!fir.char<1,5>>, !fir.ref<!fir.array<6x!fir.char<1,5>>>, !fir.slice<1>
214 ! CHECK: return
215 ! CHECK: }
217 subroutine array_substring_assignment(a)
218 character(5) :: a(6)
219 a(:)(3:5) = "BAD"
220 end subroutine array_substring_assignment
222 ! CHECK-LABEL: func @_QParray_substring_assignment2(
223 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>{{.*}}) {
224 ! CHECK: %[[VAL_1:.*]] = arith.constant 8 : index
225 ! CHECK: %[[VAL_2:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>
226 ! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
227 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
228 ! CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_4]], %[[VAL_1]], %[[VAL_4]] path %[[VAL_2]] : (index, index, index, !fir.field) -> !fir.slice<1>
229 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
230 ! CHECK: %[[sub:.*]] = arith.subi %[[VAL_1]], %[[VAL_4]] : index
231 ! CHECK: %[[add:.*]] = arith.addi %[[sub]], %[[VAL_4]] : index
232 ! CHECK: %[[div:.*]] = arith.divsi %4, %[[VAL_4]] : index
233 ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[div]], %[[c0]] : index
234 ! CHECK: %[[select:.*]] = arith.select %[[cmp]], %[[div]], %[[c0]] : index
235 ! CHECK: %[[VAL_6:.*]] = fir.array_load %[[VAL_0]](%[[VAL_3]]) {{\[}}%[[VAL_5]]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<8x!fir.char<1,7>>
236 ! CHECK: %[[VAL_7:.*]] = fir.address_of(@_QQcl.6E696365) : !fir.ref<!fir.char<1,4>>
237 ! CHECK: %[[VAL_8:.*]] = arith.constant 4 : index
238 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
239 ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
240 ! CHECK: %[[VAL_11:.*]] = arith.subi %[[select]], %[[VAL_9]] : index
241 ! CHECK: %[[VAL_12:.*]] = fir.do_loop %[[VAL_13:.*]] = %[[VAL_10]] to %[[VAL_11]] step %[[VAL_9]] unordered iter_args(%[[VAL_14:.*]] = %[[VAL_6]]) -> (!fir.array<8x!fir.char<1,7>>) {
242 ! CHECK: %[[VAL_15:.*]] = fir.array_access %[[VAL_14]], %[[VAL_13]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
243 ! CHECK: %[[VAL_16:.*]] = arith.constant 4 : i64
244 ! CHECK: %[[VAL_17:.*]] = arith.constant 7 : i64
245 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
246 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (i64) -> index
247 ! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
248 ! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_18]], %[[VAL_20]] : index
249 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_15]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
250 ! CHECK: %[[VAL_23:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_21]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
251 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
252 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_19]], %[[VAL_18]] : index
253 ! CHECK: %[[VAL_26:.*]] = arith.addi %[[VAL_25]], %[[VAL_20]] : index
254 ! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
255 ! CHECK: %[[VAL_28:.*]] = arith.cmpi slt, %[[VAL_26]], %[[VAL_27]] : index
256 ! CHECK: %[[VAL_29:.*]] = arith.select %[[VAL_28]], %[[VAL_27]], %[[VAL_26]] : index
257 ! CHECK: %[[VAL_30:.*]] = arith.constant 0 : index
258 ! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
259 ! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_29]] : (index) -> index
260 ! CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_32]], %[[VAL_31]] : index
261 ! CHECK: fir.do_loop %[[VAL_34:.*]] = %[[VAL_30]] to %[[VAL_33]] step %[[VAL_31]] {
262 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_8]] : (index) -> index
263 ! CHECK: %[[VAL_36:.*]] = arith.cmpi slt, %[[VAL_34]], %[[VAL_35]] : index
264 ! CHECK: fir.if %[[VAL_36]] {
265 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
266 ! CHECK: %[[VAL_38:.*]] = fir.coordinate_of %[[VAL_37]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
267 ! CHECK: %[[VAL_39:.*]] = fir.load %[[VAL_38]] : !fir.ref<!fir.char<1>>
268 ! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
269 ! CHECK: %[[VAL_41:.*]] = fir.coordinate_of %[[VAL_40]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
270 ! CHECK: fir.store %[[VAL_39]] to %[[VAL_41]] : !fir.ref<!fir.char<1>>
271 ! CHECK: } else {
272 ! CHECK: %[[VAL_42:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
273 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
274 ! CHECK: %[[VAL_44:.*]] = fir.coordinate_of %[[VAL_43]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
275 ! CHECK: fir.store %[[VAL_42]] to %[[VAL_44]] : !fir.ref<!fir.char<1>>
276 ! CHECK: }
277 ! CHECK: }
278 ! CHECK: %[[VAL_45:.*]] = arith.cmpi slt, %[[VAL_29]], %[[VAL_8]] : index
279 ! CHECK: %[[VAL_46:.*]] = arith.select %[[VAL_45]], %[[VAL_29]], %[[VAL_8]] : index
280 ! CHECK: %[[VAL_47:.*]] = arith.constant 1 : i64
281 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_46]] : (index) -> i64
282 ! CHECK: %[[VAL_49:.*]] = arith.muli %[[VAL_47]], %[[VAL_48]] : i64
283 ! CHECK: %[[VAL_50:.*]] = arith.constant false
284 ! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
285 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<i8>
286 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_51]], %[[VAL_52]], %[[VAL_49]], %[[VAL_50]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
287 ! CHECK: %[[VAL_53:.*]] = arith.constant 1 : index
288 ! CHECK: %[[VAL_54:.*]] = arith.subi %[[VAL_29]], %[[VAL_53]] : index
289 ! CHECK: %[[VAL_55:.*]] = arith.constant 32 : i8
290 ! CHECK: %[[VAL_56:.*]] = fir.undefined !fir.char<1>
291 ! CHECK: %[[VAL_57:.*]] = fir.insert_value %[[VAL_56]], %[[VAL_55]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
292 ! CHECK: %[[VAL_58:.*]] = arith.constant 1 : index
293 ! CHECK: fir.do_loop %[[VAL_59:.*]] = %[[VAL_46]] to %[[VAL_54]] step %[[VAL_58]] {
294 ! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
295 ! CHECK: %[[VAL_61:.*]] = fir.coordinate_of %[[VAL_60]], %[[VAL_59]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
296 ! CHECK: fir.store %[[VAL_57]] to %[[VAL_61]] : !fir.ref<!fir.char<1>>
297 ! CHECK: }
298 ! CHECK: %[[VAL_62:.*]] = fir.array_amend %[[VAL_14]], %[[VAL_15]] : (!fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.char<1,7>>) -> !fir.array<8x!fir.char<1,7>>
299 ! CHECK: fir.result %[[VAL_62]] : !fir.array<8x!fir.char<1,7>>
300 ! CHECK: }
301 ! CHECK: fir.array_merge_store %[[VAL_6]], %[[VAL_63:.*]] to %[[VAL_0]]{{\[}}%[[VAL_5]]] : !fir.array<8x!fir.char<1,7>>, !fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>, !fir.slice<1>
302 ! CHECK: return
303 ! CHECK: }
305 subroutine array_substring_assignment2(a)
306 type t
307 character(7) :: ch
308 end type t
309 type(t) :: a(8)
310 a%ch(4:7) = "nice"
311 end subroutine array_substring_assignment2
313 ! CHECK-LABEL: func @_QParray_substring_assignment3(
314 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>{{.*}}) {
315 ! CHECK: %[[VAL_2:.*]] = arith.constant 8 : index
316 ! CHECK: %[[VAL_3:.*]] = arith.constant 8 : index
317 ! CHECK: %[[VAL_4:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>
318 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
319 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
320 ! CHECK: %[[VAL_7:.*]] = fir.slice %[[VAL_6]], %[[VAL_2]], %[[VAL_6]] path %[[VAL_4]] : (index, index, index, !fir.field) -> !fir.slice<1>
321 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
322 ! CHECK: %[[sub:.*]] = arith.subi %[[VAL_2]], %[[VAL_6]] : index
323 ! CHECK: %[[add:.*]] = arith.addi %[[sub]], %[[VAL_6]] : index
324 ! CHECK: %[[div:.*]] = arith.divsi %4, %[[VAL_6]] : index
325 ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[div]], %[[c0]] : index
326 ! CHECK: %[[select:.*]] = arith.select %[[cmp]], %[[div]], %[[c0]] : index
327 ! CHECK: %[[VAL_8:.*]] = fir.array_load %[[VAL_0]](%[[VAL_5]]) {{\[}}%[[VAL_7]]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<8x!fir.char<1,7>>
328 ! CHECK: %[[VAL_9:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>
329 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
330 ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
331 ! CHECK: %[[VAL_12:.*]] = fir.slice %[[VAL_11]], %[[VAL_3]], %[[VAL_11]] path %[[VAL_9]] : (index, index, index, !fir.field) -> !fir.slice<1>
332 ! CHECK: %[[VAL_13:.*]] = fir.array_load %[[VAL_1]](%[[VAL_10]]) {{\[}}%[[VAL_12]]] : (!fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<8x!fir.char<1,7>>
333 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
334 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
335 ! CHECK: %[[VAL_16:.*]] = arith.subi %[[select]], %[[VAL_14]] : index
336 ! CHECK: %[[VAL_17:.*]] = fir.do_loop %[[VAL_18:.*]] = %[[VAL_15]] to %[[VAL_16]] step %[[VAL_14]] unordered iter_args(%[[VAL_19:.*]] = %[[VAL_8]]) -> (!fir.array<8x!fir.char<1,7>>) {
337 ! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_13]], %[[VAL_18]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
338 ! CHECK: %[[VAL_21:.*]] = arith.constant 2 : i64
339 ! CHECK: %[[VAL_22:.*]] = arith.constant 5 : i64
340 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
341 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
342 ! CHECK: %[[VAL_25:.*]] = arith.constant 1 : index
343 ! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_23]], %[[VAL_25]] : index
344 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
345 ! CHECK: %[[VAL_28:.*]] = fir.coordinate_of %[[VAL_27]], %[[VAL_26]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
346 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
347 ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_24]], %[[VAL_23]] : index
348 ! CHECK: %[[VAL_31:.*]] = arith.addi %[[VAL_30]], %[[VAL_25]] : index
349 ! CHECK: %[[VAL_32:.*]] = arith.constant 0 : index
350 ! CHECK: %[[VAL_33:.*]] = arith.cmpi slt, %[[VAL_31]], %[[VAL_32]] : index
351 ! CHECK: %[[VAL_34:.*]] = arith.select %[[VAL_33]], %[[VAL_32]], %[[VAL_31]] : index
352 ! CHECK: %[[VAL_35:.*]] = fir.array_access %[[VAL_19]], %[[VAL_18]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
353 ! CHECK: %[[VAL_36:.*]] = arith.constant 4 : i64
354 ! CHECK: %[[VAL_37:.*]] = arith.constant 7 : i64
355 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_36]] : (i64) -> index
356 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_37]] : (i64) -> index
357 ! CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
358 ! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_38]], %[[VAL_40]] : index
359 ! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
360 ! CHECK: %[[VAL_43:.*]] = fir.coordinate_of %[[VAL_42]], %[[VAL_41]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
361 ! CHECK: %[[VAL_44:.*]] = fir.convert %[[VAL_43]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
362 ! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_39]], %[[VAL_38]] : index
363 ! CHECK: %[[VAL_46:.*]] = arith.addi %[[VAL_45]], %[[VAL_40]] : index
364 ! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
365 ! CHECK: %[[VAL_48:.*]] = arith.cmpi slt, %[[VAL_46]], %[[VAL_47]] : index
366 ! CHECK: %[[VAL_49:.*]] = arith.select %[[VAL_48]], %[[VAL_47]], %[[VAL_46]] : index
367 ! CHECK: %[[VAL_50:.*]] = arith.constant 0 : index
368 ! CHECK: %[[VAL_51:.*]] = arith.constant 1 : index
369 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_49]] : (index) -> index
370 ! CHECK: %[[VAL_53:.*]] = arith.subi %[[VAL_52]], %[[VAL_51]] : index
371 ! CHECK: fir.do_loop %[[VAL_54:.*]] = %[[VAL_50]] to %[[VAL_53]] step %[[VAL_51]] {
372 ! CHECK: %[[VAL_55:.*]] = fir.convert %[[VAL_34]] : (index) -> index
373 ! CHECK: %[[VAL_56:.*]] = arith.cmpi slt, %[[VAL_54]], %[[VAL_55]] : index
374 ! CHECK: fir.if %[[VAL_56]] {
375 ! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
376 ! CHECK: %[[VAL_58:.*]] = fir.coordinate_of %[[VAL_57]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
377 ! CHECK: %[[VAL_59:.*]] = fir.load %[[VAL_58]] : !fir.ref<!fir.char<1>>
378 ! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
379 ! CHECK: %[[VAL_61:.*]] = fir.coordinate_of %[[VAL_60]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
380 ! CHECK: fir.store %[[VAL_59]] to %[[VAL_61]] : !fir.ref<!fir.char<1>>
381 ! CHECK: } else {
382 ! CHECK: %[[VAL_62:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
383 ! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
384 ! CHECK: %[[VAL_64:.*]] = fir.coordinate_of %[[VAL_63]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
385 ! CHECK: fir.store %[[VAL_62]] to %[[VAL_64]] : !fir.ref<!fir.char<1>>
386 ! CHECK: }
387 ! CHECK: }
388 ! CHECK: %[[VAL_65:.*]] = arith.cmpi slt, %[[VAL_49]], %[[VAL_34]] : index
389 ! CHECK: %[[VAL_66:.*]] = arith.select %[[VAL_65]], %[[VAL_49]], %[[VAL_34]] : index
390 ! CHECK: %[[VAL_67:.*]] = arith.constant 1 : i64
391 ! CHECK: %[[VAL_68:.*]] = fir.convert %[[VAL_66]] : (index) -> i64
392 ! CHECK: %[[VAL_69:.*]] = arith.muli %[[VAL_67]], %[[VAL_68]] : i64
393 ! CHECK: %[[VAL_70:.*]] = arith.constant false
394 ! CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
395 ! CHECK: %[[VAL_72:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
396 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_71]], %[[VAL_72]], %[[VAL_69]], %[[VAL_70]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
397 ! CHECK: %[[VAL_73:.*]] = arith.constant 1 : index
398 ! CHECK: %[[VAL_74:.*]] = arith.subi %[[VAL_49]], %[[VAL_73]] : index
399 ! CHECK: %[[VAL_75:.*]] = arith.constant 32 : i8
400 ! CHECK: %[[VAL_76:.*]] = fir.undefined !fir.char<1>
401 ! CHECK: %[[VAL_77:.*]] = fir.insert_value %[[VAL_76]], %[[VAL_75]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
402 ! CHECK: %[[VAL_78:.*]] = arith.constant 1 : index
403 ! CHECK: fir.do_loop %[[VAL_79:.*]] = %[[VAL_66]] to %[[VAL_74]] step %[[VAL_78]] {
404 ! CHECK: %[[VAL_80:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
405 ! CHECK: %[[VAL_81:.*]] = fir.coordinate_of %[[VAL_80]], %[[VAL_79]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
406 ! CHECK: fir.store %[[VAL_77]] to %[[VAL_81]] : !fir.ref<!fir.char<1>>
407 ! CHECK: }
408 ! CHECK: %[[VAL_82:.*]] = fir.array_amend %[[VAL_19]], %[[VAL_35]] : (!fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.char<1,7>>) -> !fir.array<8x!fir.char<1,7>>
409 ! CHECK: fir.result %[[VAL_82]] : !fir.array<8x!fir.char<1,7>>
410 ! CHECK: }
411 ! CHECK: fir.array_merge_store %[[VAL_8]], %[[VAL_83:.*]] to %[[VAL_0]]{{\[}}%[[VAL_7]]] : !fir.array<8x!fir.char<1,7>>, !fir.array<8x!fir.char<1,7>>, !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>>>, !fir.slice<1>
412 ! CHECK: return
413 ! CHECK: }
416 subroutine array_substring_assignment3(a,b)
417 type t
418 character(7) :: ch
419 end type t
420 type(t) :: a(8), b(8)
421 a%ch(4:7) = b%ch(2:5)
422 end subroutine array_substring_assignment3