IR: de-duplicate two CmpInst routines (NFC) (#116866)
[llvm-project.git] / flang / test / Lower / array-elemental-calls-char.f90
blob603cc677805fc9c1d6e4411b5a9e558d8016a1d7
1 ! Test lowering of elemental calls with character argument
2 ! without the VALUE attribute.
3 ! RUN: bbc -hlfir=false -o - %s | FileCheck %s
5 module char_elem
7 interface
8 elemental integer function elem(c)
9 character(*), intent(in) :: c
10 end function
12 elemental integer function elem2(c, j)
13 character(*), intent(in) :: c
14 integer, intent(in) :: j
15 end function
17 end interface
19 contains
21 ! CHECK-LABEL: func @_QMchar_elemPfoo1(
22 ! CHECK-SAME: %[[VAL_15:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_4:.*]]: !fir.boxchar<1>{{.*}}) {
23 subroutine foo1(i, c)
24 integer :: i(10)
25 character(*) :: c(10)
26 ! CHECK-DAG: %[[VAL_0:.*]] = arith.constant 10 : index
27 ! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 0 : index
28 ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index
29 ! CHECK: %[[VAL_3:.*]]:2 = fir.unboxchar %[[VAL_4]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
30 ! CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_3]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
31 ! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1>
32 ! CHECK: br ^bb1(%[[VAL_1]], %[[VAL_0]] : index, index)
33 ! CHECK: ^bb1(%[[VAL_7:.*]]: index, %[[VAL_8:.*]]: index):
34 ! CHECK: %[[VAL_9:.*]] = arith.cmpi sgt, %[[VAL_8]], %[[VAL_1]] : index
35 ! CHECK: cond_br %[[VAL_9]], ^bb2, ^bb3
36 ! CHECK: ^bb2:
37 ! CHECK: %[[VAL_10:.*]] = arith.addi %[[VAL_7]], %[[VAL_2]] : index
38 ! CHECK: %[[VAL_11:.*]] = fir.array_coor %[[VAL_5]](%[[VAL_6]]) %[[VAL_10]] typeparams %[[VAL_3]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
39 ! CHECK: %[[VAL_12:.*]] = fir.emboxchar %[[VAL_11]], %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
40 ! CHECK: %[[VAL_13:.*]] = fir.call @_QPelem(%[[VAL_12]]) {{.*}}: (!fir.boxchar<1>) -> i32
41 ! CHECK: %[[VAL_14:.*]] = fir.array_coor %[[VAL_15]](%[[VAL_6]]) %[[VAL_10]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
42 ! CHECK: fir.store %[[VAL_13]] to %[[VAL_14]] : !fir.ref<i32>
43 ! CHECK: %[[VAL_16:.*]] = arith.subi %[[VAL_8]], %[[VAL_2]] : index
44 ! CHECK: br ^bb1(%[[VAL_10]], %[[VAL_16]] : index, index)
45 ! CHECK: ^bb3:
46 ! CHECK: return
47 i = elem(c)
48 end subroutine
50 ! CHECK-LABEL: func @_QMchar_elemPfoo1b(
51 ! CHECK-SAME: %[[VAL_33:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_21:.*]]: !fir.boxchar<1>{{.*}}) {
52 subroutine foo1b(i, c)
53 integer :: i(10)
54 character(10) :: c(10)
55 ! CHECK-DAG: %[[VAL_17:.*]] = arith.constant 10 : index
56 ! CHECK-DAG: %[[VAL_18:.*]] = arith.constant 0 : index
57 ! CHECK-DAG: %[[VAL_19:.*]] = arith.constant 1 : index
58 ! CHECK: %[[VAL_20:.*]]:2 = fir.unboxchar %[[VAL_21]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
59 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_20]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,10>>>
60 ! CHECK: %[[VAL_23:.*]] = fir.shape %[[VAL_17]] : (index) -> !fir.shape<1>
61 ! CHECK: br ^bb1(%[[VAL_18]], %[[VAL_17]] : index, index)
62 ! CHECK: ^bb1(%[[VAL_24:.*]]: index, %[[VAL_25:.*]]: index):
63 ! CHECK: %[[VAL_26:.*]] = arith.cmpi sgt, %[[VAL_25]], %[[VAL_18]] : index
64 ! CHECK: cond_br %[[VAL_26]], ^bb2, ^bb3
65 ! CHECK: ^bb2:
66 ! CHECK: %[[VAL_27:.*]] = arith.addi %[[VAL_24]], %[[VAL_19]] : index
67 ! CHECK: %[[VAL_28:.*]] = fir.array_coor %[[VAL_22]](%[[VAL_23]]) %[[VAL_27]] : (!fir.ref<!fir.array<10x!fir.char<1,10>>>, !fir.shape<1>, index) -> !fir.ref<!fir.char<1,10>>
68 ! CHECK: %[[VAL_30:.*]] = fir.emboxchar %[[VAL_28]], %[[VAL_17]] : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
69 ! CHECK: %[[VAL_31:.*]] = fir.call @_QPelem(%[[VAL_30]]) {{.*}}: (!fir.boxchar<1>) -> i32
70 ! CHECK: %[[VAL_32:.*]] = fir.array_coor %[[VAL_33]](%[[VAL_23]]) %[[VAL_27]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
71 ! CHECK: fir.store %[[VAL_31]] to %[[VAL_32]] : !fir.ref<i32>
72 ! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_25]], %[[VAL_19]] : index
73 ! CHECK: br ^bb1(%[[VAL_27]], %[[VAL_34]] : index, index)
74 ! CHECK: ^bb3:
75 ! CHECK: return
76 i = elem(c)
77 end subroutine
79 ! CHECK-LABEL: func @_QMchar_elemPfoo2(
80 ! CHECK-SAME: %[[VAL_50:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_47:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_39:.*]]: !fir.boxchar<1>{{.*}}) {
81 subroutine foo2(i, j, c)
82 ! CHECK-DAG: %[[VAL_35:.*]] = arith.constant 10 : index
83 ! CHECK-DAG: %[[VAL_36:.*]] = arith.constant 0 : index
84 ! CHECK-DAG: %[[VAL_37:.*]] = arith.constant 1 : index
85 ! CHECK: %[[VAL_38:.*]]:2 = fir.unboxchar %[[VAL_39]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
86 ! CHECK: %[[VAL_40:.*]] = fir.shape %[[VAL_35]] : (index) -> !fir.shape<1>
87 ! CHECK: br ^bb1(%[[VAL_36]], %[[VAL_35]] : index, index)
88 ! CHECK: ^bb1(%[[VAL_41:.*]]: index, %[[VAL_42:.*]]: index):
89 ! CHECK: %[[VAL_43:.*]] = arith.cmpi sgt, %[[VAL_42]], %[[VAL_36]] : index
90 ! CHECK: cond_br %[[VAL_43]], ^bb2, ^bb3
91 ! CHECK: ^bb2:
92 ! CHECK: %[[VAL_44:.*]] = fir.emboxchar %[[VAL_38]]#0, %[[VAL_38]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
93 ! CHECK: %[[VAL_45:.*]] = arith.addi %[[VAL_41]], %[[VAL_37]] : index
94 ! CHECK: %[[VAL_46:.*]] = fir.array_coor %[[VAL_47]](%[[VAL_40]]) %[[VAL_45]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
95 ! CHECK: %[[VAL_48:.*]] = fir.call @_QPelem2(%[[VAL_44]], %[[VAL_46]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
96 ! CHECK: %[[VAL_49:.*]] = fir.array_coor %[[VAL_50]](%[[VAL_40]]) %[[VAL_45]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
97 ! CHECK: fir.store %[[VAL_48]] to %[[VAL_49]] : !fir.ref<i32>
98 ! CHECK: %[[VAL_51:.*]] = arith.subi %[[VAL_42]], %[[VAL_37]] : index
99 ! CHECK: br ^bb1(%[[VAL_45]], %[[VAL_51]] : index, index)
100 ! CHECK: ^bb3:
101 ! CHECK: return
102 integer :: i(10), j(10)
103 character(*) :: c
104 i = elem2(c, j)
105 end subroutine
107 ! CHECK-LABEL: func.func @_QMchar_elemPfoo2b(
108 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_2:.*]]: !fir.boxchar<1>{{.*}}) {
109 subroutine foo2b(i, j, c)
110 integer :: i(10), j(10)
111 character(10) :: c
112 ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index
113 ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index
114 ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index
115 ! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
116 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,10>>
117 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
118 ! CHECK: cf.br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index)
119 ! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
120 ! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_4]] : index
121 ! CHECK: cf.cond_br %[[VAL_11]], ^bb2, ^bb3
122 ! CHECK: ^bb2:
123 ! CHECK: %[[VAL_13:.*]] = fir.emboxchar %[[VAL_7]], %[[VAL_3]] : (!fir.ref<!fir.char<1,10>>, index) -> !fir.boxchar<1>
124 ! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_9]], %[[VAL_5]] : index
125 ! CHECK: %[[VAL_15:.*]] = fir.array_coor %[[VAL_1]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
126 ! CHECK: %[[VAL_16:.*]] = fir.call @_QPelem2(%[[VAL_13]], %[[VAL_15]]) proc_attrs<elemental, pure> fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
127 ! CHECK: %[[VAL_17:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
128 ! CHECK: fir.store %[[VAL_16]] to %[[VAL_17]] : !fir.ref<i32>
129 ! CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_10]], %[[VAL_5]] : index
130 ! CHECK: cf.br ^bb1(%[[VAL_14]], %[[VAL_18]] : index, index)
131 ! CHECK: ^bb3:
132 ! CHECK: return
133 ! CHECK: }
134 i = elem2(c, j)
135 end subroutine
137 ! CHECK-LABEL: func @_QMchar_elemPfoo3(
138 ! CHECK-SAME: %[[VAL_88:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_79:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}})
139 subroutine foo3(i, j)
140 integer :: i(10), j(10)
141 ! CHECK-DAG: %[[VAL_69:.*]] = arith.constant 10 : index
142 ! CHECK-DAG: %[[VAL_70:.*]] = arith.constant 0 : index
143 ! CHECK-DAG: %[[VAL_71:.*]] = arith.constant 1 : index
144 ! CHECK-DAG: %[[VAL_72:.*]] = fir.alloca !fir.char<1>
145 ! CHECK: %[[VAL_73:.*]] = fir.shape %[[VAL_69]] : (index) -> !fir.shape<1>
146 ! CHECK: br ^bb1(%[[VAL_70]], %[[VAL_69]] : index, index)
147 ! CHECK: ^bb1(%[[VAL_74:.*]]: index, %[[VAL_75:.*]]: index):
148 ! CHECK: %[[VAL_76:.*]] = arith.cmpi sgt, %[[VAL_75]], %[[VAL_70]] : index
149 ! CHECK: cond_br %[[VAL_76]], ^bb2, ^bb3
150 ! CHECK: ^bb2:
151 ! CHECK: %[[VAL_77:.*]] = arith.addi %[[VAL_74]], %[[VAL_71]] : index
152 ! CHECK: %[[VAL_78:.*]] = fir.array_coor %[[VAL_79]](%[[VAL_73]]) %[[VAL_77]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
153 ! CHECK: %[[VAL_80:.*]] = fir.load %[[VAL_78]] : !fir.ref<i32>
154 ! CHECK: %[[VAL_81:.*]] = fir.convert %[[VAL_80]] : (i32) -> i8
155 ! CHECK: %[[VAL_82:.*]] = fir.undefined !fir.char<1>
156 ! CHECK: %[[VAL_83:.*]] = fir.insert_value %[[VAL_82]], %[[VAL_81]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
157 ! CHECK: fir.store %[[VAL_83]] to %[[VAL_72]] : !fir.ref<!fir.char<1>>
158 ! CHECK: %[[VAL_85:.*]] = fir.emboxchar %[[VAL_72]], %[[VAL_71]] : (!fir.ref<!fir.char<1>>, index) -> !fir.boxchar<1>
159 ! CHECK: %[[VAL_86:.*]] = fir.call @_QPelem(%[[VAL_85]]) {{.*}}: (!fir.boxchar<1>) -> i32
160 ! CHECK: %[[VAL_87:.*]] = fir.array_coor %[[VAL_88]](%[[VAL_73]]) %[[VAL_77]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
161 ! CHECK: fir.store %[[VAL_86]] to %[[VAL_87]] : !fir.ref<i32>
162 ! CHECK: %[[VAL_89:.*]] = arith.subi %[[VAL_75]], %[[VAL_71]] : index
163 ! CHECK: br ^bb1(%[[VAL_77]], %[[VAL_89]] : index, index)
164 ! CHECK: ^bb3:
165 ! CHECK: return
166 i = elem(char(j))
167 end subroutine
169 ! CHECK-LABEL: func @_QMchar_elemPfoo4(
170 ! CHECK-SAME: %[[VAL_106:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_103:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}})
171 subroutine foo4(i, j)
172 integer :: i(10), j(10)
173 ! CHECK-DAG: %[[VAL_90:.*]] = arith.constant 5 : index
174 ! CHECK-DAG: %[[VAL_91:.*]] = arith.constant 10 : index
175 ! CHECK-DAG: %[[VAL_92:.*]] = arith.constant 0 : index
176 ! CHECK-DAG: %[[VAL_93:.*]] = arith.constant 1 : index
177 ! CHECK: %[[VAL_94:.*]] = fir.shape %[[VAL_91]] : (index) -> !fir.shape<1>
178 ! CHECK: %[[VAL_95:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,5>>
179 ! CHECK: br ^bb1(%[[VAL_92]], %[[VAL_91]] : index, index)
180 ! CHECK: ^bb1(%[[VAL_96:.*]]: index, %[[VAL_97:.*]]: index):
181 ! CHECK: %[[VAL_98:.*]] = arith.cmpi sgt, %[[VAL_97]], %[[VAL_92]] : index
182 ! CHECK: cond_br %[[VAL_98]], ^bb2, ^bb3
183 ! CHECK: ^bb2:
184 ! CHECK: %[[VAL_100:.*]] = fir.emboxchar %[[VAL_95]], %[[VAL_90]] : (!fir.ref<!fir.char<1,5>>, index) -> !fir.boxchar<1>
185 ! CHECK: %[[VAL_101:.*]] = arith.addi %[[VAL_96]], %[[VAL_93]] : index
186 ! CHECK: %[[VAL_102:.*]] = fir.array_coor %[[VAL_103]](%[[VAL_94]]) %[[VAL_101]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
187 ! CHECK: %[[VAL_104:.*]] = fir.call @_QPelem2(%[[VAL_100]], %[[VAL_102]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
188 ! CHECK: %[[VAL_105:.*]] = fir.array_coor %[[VAL_106]](%[[VAL_94]]) %[[VAL_101]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
189 ! CHECK: fir.store %[[VAL_104]] to %[[VAL_105]] : !fir.ref<i32>
190 ! CHECK: %[[VAL_107:.*]] = arith.subi %[[VAL_97]], %[[VAL_93]] : index
191 ! CHECK: br ^bb1(%[[VAL_101]], %[[VAL_107]] : index, index)
192 ! CHECK: ^bb3:
193 ! CHECK: return
194 i = elem2("hello", j)
195 end subroutine
197 ! Test character return for elemental functions.
199 ! CHECK-LABEL: func @_QMchar_elemPelem_return_char(
200 ! CHECK-SAME: %{{.*}}: !fir.ref<!fir.char<1,?>>{{.*}}, %{{.*}}: index{{.*}}, %{{.*}}: !fir.boxchar<1>{{.*}}) -> !fir.boxchar<1>
201 elemental function elem_return_char(c)
202 character(*), intent(in) :: c
203 character(len(c)) :: elem_return_char
204 elem_return_char = "ab" // c
205 end function
207 ! CHECK-LABEL: func @_QMchar_elemPfoo6(
208 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
209 subroutine foo6(c)
210 ! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 10 : index
211 ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index
212 ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index
213 ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant false
214 ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 32 : i8
215 ! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
216 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
217 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
218 ! CHECK: br ^bb1(%[[VAL_3]], %[[VAL_1]] : index, index)
219 ! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
220 ! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_3]] : index
221 ! CHECK: cond_br %[[VAL_11]], ^bb2, ^bb6
222 ! CHECK: ^bb2:
223 ! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_9]], %[[VAL_2]] : index
224 ! CHECK: %[[VAL_13:.*]] = fir.array_coor %[[VAL_7]](%[[VAL_8]]) %[[VAL_12]] typeparams %[[VAL_6]]#1 : (!fir.ref<!fir.array<10x!fir.char<1,?>>>, !fir.shape<1>, index, index) -> !fir.ref<!fir.char<1,?>>
225 ! CHECK: %[[VAL_14:.*]] = fir.emboxchar %[[VAL_13]], %[[VAL_6]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
226 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_6]]#1 : (index) -> i32
227 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> index
228 ! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_16]], %{{.*}} : index
229 ! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_16]], %{{.*}} : index
230 ! CHECK: %[[VAL_17:.*]] = llvm.intr.stacksave : !llvm.ptr
231 ! CHECK: %[[VAL_18:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT]] : index) {bindc_name = ".result"}
232 ! CHECK: %[[VAL_19:.*]] = fir.call @_QMchar_elemPelem_return_char(%[[VAL_18]], %[[SELECT]], %[[VAL_14]]) {{.*}}: (!fir.ref<!fir.char<1,?>>, index, !fir.boxchar<1>) -> !fir.boxchar<1>
233 ! CHECK: %[[VAL_20:.*]] = arith.cmpi slt, %[[VAL_6]]#1, %[[SELECT]] : index
234 ! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_6]]#1, %[[SELECT]] : index
235 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (index) -> i64
236 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
237 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
238 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_23]], %[[VAL_24]], %[[VAL_22]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
239 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_6]]#1, %[[VAL_2]] : index
240 ! CHECK: %[[VAL_26:.*]] = fir.undefined !fir.char<1>
241 ! CHECK: %[[VAL_27:.*]] = fir.insert_value %[[VAL_26]], %[[VAL_5]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
242 ! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_25]], %[[VAL_21]] : index
243 ! CHECK: %[[VAL_29:.*]] = arith.addi %[[VAL_28]], %[[VAL_2]] : index
244 ! CHECK: br ^bb3(%[[VAL_21]], %[[VAL_29]] : index, index)
245 ! CHECK: ^bb3(%[[VAL_30:.*]]: index, %[[VAL_31:.*]]: index):
246 ! CHECK: %[[VAL_32:.*]] = arith.cmpi sgt, %[[VAL_31]], %[[VAL_3]] : index
247 ! CHECK: cond_br %[[VAL_32]], ^bb4, ^bb5
248 ! CHECK: ^bb4:
249 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
250 ! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_30]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
251 ! CHECK: fir.store %[[VAL_27]] to %[[VAL_34]] : !fir.ref<!fir.char<1>>
252 ! CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_30]], %[[VAL_2]] : index
253 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_31]], %[[VAL_2]] : index
254 ! CHECK: br ^bb3(%[[VAL_35]], %[[VAL_36]] : index, index)
255 ! CHECK: ^bb5:
256 ! CHECK: llvm.intr.stackrestore %[[VAL_17]] : !llvm.ptr
257 ! CHECK: %[[VAL_37:.*]] = arith.subi %[[VAL_10]], %[[VAL_2]] : index
258 ! CHECK: br ^bb1(%[[VAL_12]], %[[VAL_37]] : index, index)
259 ! CHECK: ^bb6:
261 implicit none
262 character(*) :: c(10)
263 c = elem_return_char(c)
264 ! CHECK: return
265 ! CHECK: }
266 end subroutine
268 end module