IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / flang / test / Lower / character-substrings.f90
blob874f2944cff1992ef29e6d06d4d3596852fb5f5b
1 ! Test character substring lowering
2 ! RUN: bbc %s -o - -emit-fir -hlfir=false | 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(@_QQclX{{.*}}) : !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:.*]] = fir.convert %[[VAL_2]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,4>>
74 ! CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[VAL_1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
75 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,4>>
76 ! CHECK: %[[VAL_6:.*]] = arith.constant 3 : i64
77 ! CHECK: %[[VAL_7:.*]] = arith.constant 4 : i64
78 ! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_6]] : (i64) -> index
79 ! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
80 ! CHECK: %[[VAL_10:.*]] = arith.constant 1 : index
81 ! CHECK: %[[VAL_11:.*]] = arith.subi %[[VAL_8]], %[[VAL_10]] : index
82 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_5]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<4x!fir.char<1>>>
83 ! CHECK: %[[VAL_13:.*]] = fir.coordinate_of %[[VAL_12]], %[[VAL_11]] : (!fir.ref<!fir.array<4x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
84 ! CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
85 ! CHECK: %[[VAL_15:.*]] = arith.subi %[[VAL_9]], %[[VAL_8]] : index
86 ! CHECK: %[[VAL_16:.*]] = arith.addi %[[VAL_15]], %[[VAL_10]] : index
87 ! CHECK: %[[VAL_17:.*]] = arith.constant 0 : index
88 ! CHECK: %[[VAL_18:.*]] = arith.cmpi slt, %[[VAL_16]], %[[VAL_17]] : index
89 ! CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_17]], %[[VAL_16]] : index
90 ! CHECK: %[[VAL_20:.*]] = arith.constant 1 : i64
91 ! CHECK: %[[VAL_21:.*]] = arith.constant 2 : i64
92 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]] : (i64) -> index
93 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
94 ! CHECK: %[[VAL_24:.*]] = arith.constant 1 : index
95 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_22]], %[[VAL_24]] : index
96 ! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_3]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<4x!fir.char<1>>>
97 ! CHECK: %[[VAL_27:.*]] = fir.coordinate_of %[[VAL_26]], %[[VAL_25]] : (!fir.ref<!fir.array<4x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
98 ! CHECK: %[[VAL_28:.*]] = fir.convert %[[VAL_27]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
99 ! CHECK: %[[VAL_29:.*]] = arith.subi %[[VAL_23]], %[[VAL_22]] : index
100 ! CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_29]], %[[VAL_24]] : index
101 ! CHECK: %[[VAL_31:.*]] = arith.constant 0 : index
102 ! CHECK: %[[VAL_32:.*]] = arith.cmpi slt, %[[VAL_30]], %[[VAL_31]] : index
103 ! CHECK: %[[VAL_33:.*]] = arith.select %[[VAL_32]], %[[VAL_31]], %[[VAL_30]] : index
104 ! CHECK: %[[VAL_34:.*]] = arith.cmpi slt, %[[VAL_33]], %[[VAL_19]] : index
105 ! CHECK: %[[VAL_35:.*]] = arith.select %[[VAL_34]], %[[VAL_33]], %[[VAL_19]] : index
106 ! CHECK: %[[VAL_36:.*]] = arith.constant 1 : i64
107 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_35]] : (index) -> i64
108 ! CHECK: %[[VAL_38:.*]] = arith.muli %[[VAL_36]], %[[VAL_37]] : i64
109 ! CHECK: %[[VAL_39:.*]] = arith.constant false
110 ! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
111 ! CHECK: %[[VAL_41:.*]] = fir.convert %[[VAL_14]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
112 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_40]], %[[VAL_41]], %[[VAL_38]], %[[VAL_39]]) fastmath<contract> : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
113 ! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
114 ! CHECK: %[[VAL_43:.*]] = arith.subi %[[VAL_33]], %[[VAL_42]] : index
115 ! CHECK: %[[VAL_44:.*]] = arith.constant 32 : i8
116 ! CHECK: %[[VAL_45:.*]] = fir.undefined !fir.char<1>
117 ! CHECK: %[[VAL_46:.*]] = fir.insert_value %[[VAL_45]], %[[VAL_44]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
118 ! CHECK: %[[VAL_47:.*]] = arith.constant 1 : index
119 ! CHECK: fir.do_loop %[[VAL_48:.*]] = %[[VAL_35]] to %[[VAL_43]] step %[[VAL_47]] {
120 ! CHECK: %[[VAL_49:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
121 ! CHECK: %[[VAL_50:.*]] = fir.coordinate_of %[[VAL_49]], %[[VAL_48]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
122 ! CHECK: fir.store %[[VAL_46]] to %[[VAL_50]] : !fir.ref<!fir.char<1>>
123 ! CHECK: }
124 ! CHECK: return
125 ! CHECK: }
127 character(4) :: a, b
128 a(1:2) = b(3:4)
129 end subroutine substring_assignment
131 ! CHECK-LABEL: func @_QParray_substring_assignment(
132 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>{{.*}}) {
133 ! CHECK: %[[VAL_1:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
134 ! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_1]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<6x!fir.char<1,5>>>
135 ! CHECK: %[[VAL_3:.*]] = arith.constant 6 : index
136 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
137 ! CHECK: %[[VAL_5:.*]] = arith.constant 1 : i64
138 ! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (i64) -> index
139 ! CHECK: %[[VAL_7:.*]] = arith.addi %[[VAL_4]], %[[VAL_3]] : index
140 ! CHECK: %[[VAL_8:.*]] = arith.subi %[[VAL_7]], %[[VAL_4]] : index
141 ! CHECK: %[[VAL_9:.*]] = arith.constant 0 : index
142 ! CHECK: %[[VAL_10:.*]] = arith.subi %[[VAL_8]], %[[VAL_4]] : index
143 ! CHECK: %[[VAL_11:.*]] = arith.addi %[[VAL_10]], %[[VAL_6]] : index
144 ! CHECK: %[[VAL_12:.*]] = arith.divsi %[[VAL_11]], %[[VAL_6]] : index
145 ! CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[VAL_9]] : index
146 ! CHECK: %[[VAL_14:.*]] = arith.select %[[VAL_13]], %[[VAL_12]], %[[VAL_9]] : index
147 ! CHECK: %[[VAL_15:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
148 ! CHECK: %[[VAL_16:.*]] = fir.slice %[[VAL_4]], %[[VAL_8]], %[[VAL_6]] : (index, index, index) -> !fir.slice<1>
149 ! 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>>
150 ! CHECK: %[[VAL_18:.*]] = fir.address_of(@_QQclX424144) : !fir.ref<!fir.char<1,3>>
151 ! CHECK: %[[VAL_19:.*]] = arith.constant 3 : index
152 ! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
153 ! CHECK: %[[VAL_21:.*]] = arith.constant 0 : index
154 ! CHECK: %[[VAL_22:.*]] = arith.subi %[[VAL_14]], %[[VAL_20]] : index
155 ! 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>>) {
156 ! CHECK: %[[VAL_26:.*]] = fir.array_access %[[VAL_25]], %[[VAL_24]] : (!fir.array<6x!fir.char<1,5>>, index) -> !fir.ref<!fir.char<1,5>>
157 ! CHECK: %[[VAL_27:.*]] = arith.constant 3 : i64
158 ! CHECK: %[[VAL_28:.*]] = arith.constant 5 : i64
159 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_27]] : (i64) -> index
160 ! CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_28]] : (i64) -> index
161 ! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
162 ! CHECK: %[[VAL_32:.*]] = arith.subi %[[VAL_29]], %[[VAL_31]] : index
163 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<!fir.array<5x!fir.char<1>>>
164 ! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_32]] : (!fir.ref<!fir.array<5x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
165 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_34]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
166 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_30]], %[[VAL_29]] : index
167 ! CHECK: %[[VAL_37:.*]] = arith.addi %[[VAL_36]], %[[VAL_31]] : index
168 ! CHECK: %[[VAL_38:.*]] = arith.constant 0 : index
169 ! CHECK: %[[VAL_39:.*]] = arith.cmpi slt, %[[VAL_37]], %[[VAL_38]] : index
170 ! CHECK: %[[VAL_40:.*]] = arith.select %[[VAL_39]], %[[VAL_38]], %[[VAL_37]] : index
171 ! CHECK: %[[VAL_41:.*]] = arith.constant 0 : index
172 ! CHECK: %[[VAL_42:.*]] = arith.constant 1 : index
173 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_40]] : (index) -> index
174 ! CHECK: %[[VAL_44:.*]] = arith.subi %[[VAL_43]], %[[VAL_42]] : index
175 ! CHECK: fir.do_loop %[[VAL_45:.*]] = %[[VAL_41]] to %[[VAL_44]] step %[[VAL_42]] {
176 ! CHECK: %[[VAL_46:.*]] = fir.convert %[[VAL_19]] : (index) -> index
177 ! CHECK: %[[VAL_47:.*]] = arith.cmpi slt, %[[VAL_45]], %[[VAL_46]] : index
178 ! CHECK: fir.if %[[VAL_47]] {
179 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
180 ! CHECK: %[[VAL_49:.*]] = fir.coordinate_of %[[VAL_48]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
181 ! CHECK: %[[VAL_50:.*]] = fir.load %[[VAL_49]] : !fir.ref<!fir.char<1>>
182 ! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
183 ! CHECK: %[[VAL_52:.*]] = fir.coordinate_of %[[VAL_51]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
184 ! CHECK: fir.store %[[VAL_50]] to %[[VAL_52]] : !fir.ref<!fir.char<1>>
185 ! CHECK: } else {
186 ! CHECK: %[[VAL_53:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
187 ! CHECK: %[[VAL_54:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
188 ! CHECK: %[[VAL_55:.*]] = fir.coordinate_of %[[VAL_54]], %[[VAL_45]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
189 ! CHECK: fir.store %[[VAL_53]] to %[[VAL_55]] : !fir.ref<!fir.char<1>>
190 ! CHECK: }
191 ! CHECK: }
192 ! CHECK: %[[VAL_56:.*]] = arith.cmpi slt, %[[VAL_40]], %[[VAL_19]] : index
193 ! CHECK: %[[VAL_57:.*]] = arith.select %[[VAL_56]], %[[VAL_40]], %[[VAL_19]] : index
194 ! CHECK: %[[VAL_58:.*]] = arith.constant 1 : i64
195 ! CHECK: %[[VAL_59:.*]] = fir.convert %[[VAL_57]] : (index) -> i64
196 ! CHECK: %[[VAL_60:.*]] = arith.muli %[[VAL_58]], %[[VAL_59]] : i64
197 ! CHECK: %[[VAL_61:.*]] = arith.constant false
198 ! CHECK: %[[VAL_62:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
199 ! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,3>>) -> !fir.ref<i8>
200 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_62]], %[[VAL_63]], %[[VAL_60]], %[[VAL_61]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
201 ! CHECK: %[[VAL_64:.*]] = arith.constant 1 : index
202 ! CHECK: %[[VAL_65:.*]] = arith.subi %[[VAL_40]], %[[VAL_64]] : index
203 ! CHECK: %[[VAL_66:.*]] = arith.constant 32 : i8
204 ! CHECK: %[[VAL_67:.*]] = fir.undefined !fir.char<1>
205 ! CHECK: %[[VAL_68:.*]] = fir.insert_value %[[VAL_67]], %[[VAL_66]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
206 ! CHECK: %[[VAL_69:.*]] = arith.constant 1 : index
207 ! CHECK: fir.do_loop %[[VAL_70:.*]] = %[[VAL_57]] to %[[VAL_65]] step %[[VAL_69]] {
208 ! CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
209 ! CHECK: %[[VAL_72:.*]] = fir.coordinate_of %[[VAL_71]], %[[VAL_70]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
210 ! CHECK: fir.store %[[VAL_68]] to %[[VAL_72]] : !fir.ref<!fir.char<1>>
211 ! CHECK: }
212 ! 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>>
213 ! CHECK: fir.result %[[VAL_73]] : !fir.array<6x!fir.char<1,5>>
214 ! CHECK: }
215 ! 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>
216 ! CHECK: return
217 ! CHECK: }
219 subroutine array_substring_assignment(a)
220 character(5) :: a(6)
221 a(:)(3:5) = "BAD"
222 end subroutine array_substring_assignment
224 ! CHECK-LABEL: func @_QParray_substring_assignment2(
225 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<8x!fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>>>{{.*}}) {
226 ! CHECK: %[[VAL_1:.*]] = arith.constant 8 : index
227 ! CHECK: %[[VAL_2:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment2Tt{ch:!fir.char<1,7>}>
228 ! CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
229 ! CHECK: %[[VAL_4:.*]] = arith.constant 1 : index
230 ! CHECK: %[[VAL_5:.*]] = fir.slice %[[VAL_4]], %[[VAL_1]], %[[VAL_4]] path %[[VAL_2]] : (index, index, index, !fir.field) -> !fir.slice<1>
231 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
232 ! CHECK: %[[sub:.*]] = arith.subi %[[VAL_1]], %[[VAL_4]] : index
233 ! CHECK: %[[add:.*]] = arith.addi %[[sub]], %[[VAL_4]] : index
234 ! CHECK: %[[div:.*]] = arith.divsi %{{[0-9]+}}, %[[VAL_4]] : index
235 ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[div]], %[[c0]] : index
236 ! CHECK: %[[select:.*]] = arith.select %[[cmp]], %[[div]], %[[c0]] : index
237 ! 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>>
238 ! CHECK: %[[VAL_7:.*]] = fir.address_of(@_QQclX6E696365) : !fir.ref<!fir.char<1,4>>
239 ! CHECK: %[[VAL_8:.*]] = arith.constant 4 : index
240 ! CHECK: %[[VAL_9:.*]] = arith.constant 1 : index
241 ! CHECK: %[[VAL_10:.*]] = arith.constant 0 : index
242 ! CHECK: %[[VAL_11:.*]] = arith.subi %[[select]], %[[VAL_9]] : index
243 ! 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>>) {
244 ! CHECK: %[[VAL_15:.*]] = fir.array_access %[[VAL_14]], %[[VAL_13]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
245 ! CHECK: %[[VAL_16:.*]] = arith.constant 4 : i64
246 ! CHECK: %[[VAL_17:.*]] = arith.constant 7 : i64
247 ! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_16]] : (i64) -> index
248 ! CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_17]] : (i64) -> index
249 ! CHECK: %[[VAL_20:.*]] = arith.constant 1 : index
250 ! CHECK: %[[VAL_21:.*]] = arith.subi %[[VAL_18]], %[[VAL_20]] : index
251 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_15]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
252 ! CHECK: %[[VAL_23:.*]] = fir.coordinate_of %[[VAL_22]], %[[VAL_21]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
253 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_23]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
254 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_19]], %[[VAL_18]] : index
255 ! CHECK: %[[VAL_26:.*]] = arith.addi %[[VAL_25]], %[[VAL_20]] : index
256 ! CHECK: %[[VAL_27:.*]] = arith.constant 0 : index
257 ! CHECK: %[[VAL_28:.*]] = arith.cmpi slt, %[[VAL_26]], %[[VAL_27]] : index
258 ! CHECK: %[[VAL_29:.*]] = arith.select %[[VAL_28]], %[[VAL_27]], %[[VAL_26]] : index
259 ! CHECK: %[[VAL_30:.*]] = arith.constant 0 : index
260 ! CHECK: %[[VAL_31:.*]] = arith.constant 1 : index
261 ! CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_29]] : (index) -> index
262 ! CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_32]], %[[VAL_31]] : index
263 ! CHECK: fir.do_loop %[[VAL_34:.*]] = %[[VAL_30]] to %[[VAL_33]] step %[[VAL_31]] {
264 ! CHECK: %[[VAL_35:.*]] = fir.convert %[[VAL_8]] : (index) -> index
265 ! CHECK: %[[VAL_36:.*]] = arith.cmpi slt, %[[VAL_34]], %[[VAL_35]] : index
266 ! CHECK: fir.if %[[VAL_36]] {
267 ! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
268 ! CHECK: %[[VAL_38:.*]] = fir.coordinate_of %[[VAL_37]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
269 ! CHECK: %[[VAL_39:.*]] = fir.load %[[VAL_38]] : !fir.ref<!fir.char<1>>
270 ! CHECK: %[[VAL_40:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
271 ! CHECK: %[[VAL_41:.*]] = fir.coordinate_of %[[VAL_40]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
272 ! CHECK: fir.store %[[VAL_39]] to %[[VAL_41]] : !fir.ref<!fir.char<1>>
273 ! CHECK: } else {
274 ! CHECK: %[[VAL_42:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
275 ! CHECK: %[[VAL_43:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
276 ! CHECK: %[[VAL_44:.*]] = fir.coordinate_of %[[VAL_43]], %[[VAL_34]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
277 ! CHECK: fir.store %[[VAL_42]] to %[[VAL_44]] : !fir.ref<!fir.char<1>>
278 ! CHECK: }
279 ! CHECK: }
280 ! CHECK: %[[VAL_45:.*]] = arith.cmpi slt, %[[VAL_29]], %[[VAL_8]] : index
281 ! CHECK: %[[VAL_46:.*]] = arith.select %[[VAL_45]], %[[VAL_29]], %[[VAL_8]] : index
282 ! CHECK: %[[VAL_47:.*]] = arith.constant 1 : i64
283 ! CHECK: %[[VAL_48:.*]] = fir.convert %[[VAL_46]] : (index) -> i64
284 ! CHECK: %[[VAL_49:.*]] = arith.muli %[[VAL_47]], %[[VAL_48]] : i64
285 ! CHECK: %[[VAL_50:.*]] = arith.constant false
286 ! CHECK: %[[VAL_51:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
287 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,4>>) -> !fir.ref<i8>
288 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_51]], %[[VAL_52]], %[[VAL_49]], %[[VAL_50]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
289 ! CHECK: %[[VAL_53:.*]] = arith.constant 1 : index
290 ! CHECK: %[[VAL_54:.*]] = arith.subi %[[VAL_29]], %[[VAL_53]] : index
291 ! CHECK: %[[VAL_55:.*]] = arith.constant 32 : i8
292 ! CHECK: %[[VAL_56:.*]] = fir.undefined !fir.char<1>
293 ! CHECK: %[[VAL_57:.*]] = fir.insert_value %[[VAL_56]], %[[VAL_55]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
294 ! CHECK: %[[VAL_58:.*]] = arith.constant 1 : index
295 ! CHECK: fir.do_loop %[[VAL_59:.*]] = %[[VAL_46]] to %[[VAL_54]] step %[[VAL_58]] {
296 ! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
297 ! CHECK: %[[VAL_61:.*]] = fir.coordinate_of %[[VAL_60]], %[[VAL_59]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
298 ! CHECK: fir.store %[[VAL_57]] to %[[VAL_61]] : !fir.ref<!fir.char<1>>
299 ! CHECK: }
300 ! 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>>
301 ! CHECK: fir.result %[[VAL_62]] : !fir.array<8x!fir.char<1,7>>
302 ! CHECK: }
303 ! 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>
304 ! CHECK: return
305 ! CHECK: }
307 subroutine array_substring_assignment2(a)
308 type t
309 character(7) :: ch
310 end type t
311 type(t) :: a(8)
312 a%ch(4:7) = "nice"
313 end subroutine array_substring_assignment2
315 ! CHECK-LABEL: func @_QParray_substring_assignment3(
316 ! 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>}>>>{{.*}}) {
317 ! CHECK: %[[VAL_2:.*]] = arith.constant 8 : index
318 ! CHECK: %[[VAL_3:.*]] = arith.constant 8 : index
319 ! CHECK: %[[VAL_4:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>
320 ! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
321 ! CHECK: %[[VAL_6:.*]] = arith.constant 1 : index
322 ! CHECK: %[[VAL_7:.*]] = fir.slice %[[VAL_6]], %[[VAL_2]], %[[VAL_6]] path %[[VAL_4]] : (index, index, index, !fir.field) -> !fir.slice<1>
323 ! CHECK: %[[c0:.*]] = arith.constant 0 : index
324 ! CHECK: %[[sub:.*]] = arith.subi %[[VAL_2]], %[[VAL_6]] : index
325 ! CHECK: %[[add:.*]] = arith.addi %[[sub]], %[[VAL_6]] : index
326 ! CHECK: %[[div:.*]] = arith.divsi %[[add]], %[[VAL_6]] : index
327 ! CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[div]], %[[c0]] : index
328 ! CHECK: %[[select:.*]] = arith.select %[[cmp]], %[[div]], %[[c0]] : index
329 ! 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>>
330 ! CHECK: %[[VAL_9:.*]] = fir.field_index ch, !fir.type<_QFarray_substring_assignment3Tt{ch:!fir.char<1,7>}>
331 ! CHECK: %[[VAL_10:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
332 ! CHECK: %[[VAL_11:.*]] = arith.constant 1 : index
333 ! CHECK: %[[VAL_12:.*]] = fir.slice %[[VAL_11]], %[[VAL_3]], %[[VAL_11]] path %[[VAL_9]] : (index, index, index, !fir.field) -> !fir.slice<1>
334 ! 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>>
335 ! CHECK: %[[VAL_14:.*]] = arith.constant 1 : index
336 ! CHECK: %[[VAL_15:.*]] = arith.constant 0 : index
337 ! CHECK: %[[VAL_16:.*]] = arith.subi %[[select]], %[[VAL_14]] : index
338 ! 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>>) {
339 ! CHECK: %[[VAL_20:.*]] = fir.array_access %[[VAL_13]], %[[VAL_18]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
340 ! CHECK: %[[VAL_21:.*]] = arith.constant 2 : i64
341 ! CHECK: %[[VAL_22:.*]] = arith.constant 5 : i64
342 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_21]] : (i64) -> index
343 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_22]] : (i64) -> index
344 ! CHECK: %[[VAL_25:.*]] = arith.constant 1 : index
345 ! CHECK: %[[VAL_26:.*]] = arith.subi %[[VAL_23]], %[[VAL_25]] : index
346 ! CHECK: %[[VAL_27:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
347 ! CHECK: %[[VAL_28:.*]] = fir.coordinate_of %[[VAL_27]], %[[VAL_26]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
348 ! CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
349 ! CHECK: %[[VAL_30:.*]] = arith.subi %[[VAL_24]], %[[VAL_23]] : index
350 ! CHECK: %[[VAL_31:.*]] = arith.addi %[[VAL_30]], %[[VAL_25]] : index
351 ! CHECK: %[[VAL_32:.*]] = arith.constant 0 : index
352 ! CHECK: %[[VAL_33:.*]] = arith.cmpi slt, %[[VAL_31]], %[[VAL_32]] : index
353 ! CHECK: %[[VAL_34:.*]] = arith.select %[[VAL_33]], %[[VAL_32]], %[[VAL_31]] : index
354 ! CHECK: %[[VAL_35:.*]] = fir.array_access %[[VAL_19]], %[[VAL_18]] : (!fir.array<8x!fir.char<1,7>>, index) -> !fir.ref<!fir.char<1,7>>
355 ! CHECK: %[[VAL_36:.*]] = arith.constant 4 : i64
356 ! CHECK: %[[VAL_37:.*]] = arith.constant 7 : i64
357 ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_36]] : (i64) -> index
358 ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_37]] : (i64) -> index
359 ! CHECK: %[[VAL_40:.*]] = arith.constant 1 : index
360 ! CHECK: %[[VAL_41:.*]] = arith.subi %[[VAL_38]], %[[VAL_40]] : index
361 ! CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_35]] : (!fir.ref<!fir.char<1,7>>) -> !fir.ref<!fir.array<7x!fir.char<1>>>
362 ! CHECK: %[[VAL_43:.*]] = fir.coordinate_of %[[VAL_42]], %[[VAL_41]] : (!fir.ref<!fir.array<7x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
363 ! CHECK: %[[VAL_44:.*]] = fir.convert %[[VAL_43]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
364 ! CHECK: %[[VAL_45:.*]] = arith.subi %[[VAL_39]], %[[VAL_38]] : index
365 ! CHECK: %[[VAL_46:.*]] = arith.addi %[[VAL_45]], %[[VAL_40]] : index
366 ! CHECK: %[[VAL_47:.*]] = arith.constant 0 : index
367 ! CHECK: %[[VAL_48:.*]] = arith.cmpi slt, %[[VAL_46]], %[[VAL_47]] : index
368 ! CHECK: %[[VAL_49:.*]] = arith.select %[[VAL_48]], %[[VAL_47]], %[[VAL_46]] : index
369 ! CHECK: %[[VAL_50:.*]] = arith.constant 0 : index
370 ! CHECK: %[[VAL_51:.*]] = arith.constant 1 : index
371 ! CHECK: %[[VAL_52:.*]] = fir.convert %[[VAL_49]] : (index) -> index
372 ! CHECK: %[[VAL_53:.*]] = arith.subi %[[VAL_52]], %[[VAL_51]] : index
373 ! CHECK: fir.do_loop %[[VAL_54:.*]] = %[[VAL_50]] to %[[VAL_53]] step %[[VAL_51]] {
374 ! CHECK: %[[VAL_55:.*]] = fir.convert %[[VAL_34]] : (index) -> index
375 ! CHECK: %[[VAL_56:.*]] = arith.cmpi slt, %[[VAL_54]], %[[VAL_55]] : index
376 ! CHECK: fir.if %[[VAL_56]] {
377 ! CHECK: %[[VAL_57:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
378 ! CHECK: %[[VAL_58:.*]] = fir.coordinate_of %[[VAL_57]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
379 ! CHECK: %[[VAL_59:.*]] = fir.load %[[VAL_58]] : !fir.ref<!fir.char<1>>
380 ! CHECK: %[[VAL_60:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
381 ! CHECK: %[[VAL_61:.*]] = fir.coordinate_of %[[VAL_60]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
382 ! CHECK: fir.store %[[VAL_59]] to %[[VAL_61]] : !fir.ref<!fir.char<1>>
383 ! CHECK: } else {
384 ! CHECK: %[[VAL_62:.*]] = fir.string_lit [32 : i8](1) : !fir.char<1>
385 ! CHECK: %[[VAL_63:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
386 ! CHECK: %[[VAL_64:.*]] = fir.coordinate_of %[[VAL_63]], %[[VAL_54]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
387 ! CHECK: fir.store %[[VAL_62]] to %[[VAL_64]] : !fir.ref<!fir.char<1>>
388 ! CHECK: }
389 ! CHECK: }
390 ! CHECK: %[[VAL_65:.*]] = arith.cmpi slt, %[[VAL_49]], %[[VAL_34]] : index
391 ! CHECK: %[[VAL_66:.*]] = arith.select %[[VAL_65]], %[[VAL_49]], %[[VAL_34]] : index
392 ! CHECK: %[[VAL_67:.*]] = arith.constant 1 : i64
393 ! CHECK: %[[VAL_68:.*]] = fir.convert %[[VAL_66]] : (index) -> i64
394 ! CHECK: %[[VAL_69:.*]] = arith.muli %[[VAL_67]], %[[VAL_68]] : i64
395 ! CHECK: %[[VAL_70:.*]] = arith.constant false
396 ! CHECK: %[[VAL_71:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
397 ! CHECK: %[[VAL_72:.*]] = fir.convert %[[VAL_29]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
398 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_71]], %[[VAL_72]], %[[VAL_69]], %[[VAL_70]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
399 ! CHECK: %[[VAL_73:.*]] = arith.constant 1 : index
400 ! CHECK: %[[VAL_74:.*]] = arith.subi %[[VAL_49]], %[[VAL_73]] : index
401 ! CHECK: %[[VAL_75:.*]] = arith.constant 32 : i8
402 ! CHECK: %[[VAL_76:.*]] = fir.undefined !fir.char<1>
403 ! CHECK: %[[VAL_77:.*]] = fir.insert_value %[[VAL_76]], %[[VAL_75]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
404 ! CHECK: %[[VAL_78:.*]] = arith.constant 1 : index
405 ! CHECK: fir.do_loop %[[VAL_79:.*]] = %[[VAL_66]] to %[[VAL_74]] step %[[VAL_78]] {
406 ! CHECK: %[[VAL_80:.*]] = fir.convert %[[VAL_44]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
407 ! CHECK: %[[VAL_81:.*]] = fir.coordinate_of %[[VAL_80]], %[[VAL_79]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
408 ! CHECK: fir.store %[[VAL_77]] to %[[VAL_81]] : !fir.ref<!fir.char<1>>
409 ! CHECK: }
410 ! 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>>
411 ! CHECK: fir.result %[[VAL_82]] : !fir.array<8x!fir.char<1,7>>
412 ! CHECK: }
413 ! 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>
414 ! CHECK: return
415 ! CHECK: }
418 subroutine array_substring_assignment3(a,b)
419 type t
420 character(7) :: ch
421 end type t
422 type(t) :: a(8), b(8)
423 a%ch(4:7) = b%ch(2:5)
424 end subroutine array_substring_assignment3