[flang][openacc] Use OpenACC terminator instead of fir.unreachable after Stop stmt...
[llvm-project.git] / flang / test / Lower / array-elemental-calls-char.f90
blob9dea4d224f9400ba1cad2a6f24457be489b5db94
1 ! Test lowering of elemental calls with character argument
2 ! without the VALUE attribute.
3 ! RUN: bbc -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_29:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.char<1,?>>
69 ! CHECK: %[[VAL_30:.*]] = fir.emboxchar %[[VAL_29]], %[[VAL_17]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
70 ! CHECK: %[[VAL_31:.*]] = fir.call @_QPelem(%[[VAL_30]]) {{.*}}: (!fir.boxchar<1>) -> i32
71 ! CHECK: %[[VAL_32:.*]] = fir.array_coor %[[VAL_33]](%[[VAL_23]]) %[[VAL_27]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
72 ! CHECK: fir.store %[[VAL_31]] to %[[VAL_32]] : !fir.ref<i32>
73 ! CHECK: %[[VAL_34:.*]] = arith.subi %[[VAL_25]], %[[VAL_19]] : index
74 ! CHECK: br ^bb1(%[[VAL_27]], %[[VAL_34]] : index, index)
75 ! CHECK: ^bb3:
76 ! CHECK: return
77 i = elem(c)
78 end subroutine
80 ! CHECK-LABEL: func @_QMchar_elemPfoo2(
81 ! CHECK-SAME: %[[VAL_50:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_47:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_39:.*]]: !fir.boxchar<1>{{.*}}) {
82 subroutine foo2(i, j, c)
83 ! CHECK-DAG: %[[VAL_35:.*]] = arith.constant 10 : index
84 ! CHECK-DAG: %[[VAL_36:.*]] = arith.constant 0 : index
85 ! CHECK-DAG: %[[VAL_37:.*]] = arith.constant 1 : index
86 ! CHECK: %[[VAL_38:.*]]:2 = fir.unboxchar %[[VAL_39]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
87 ! CHECK: %[[VAL_40:.*]] = fir.shape %[[VAL_35]] : (index) -> !fir.shape<1>
88 ! CHECK: br ^bb1(%[[VAL_36]], %[[VAL_35]] : index, index)
89 ! CHECK: ^bb1(%[[VAL_41:.*]]: index, %[[VAL_42:.*]]: index):
90 ! CHECK: %[[VAL_43:.*]] = arith.cmpi sgt, %[[VAL_42]], %[[VAL_36]] : index
91 ! CHECK: cond_br %[[VAL_43]], ^bb2, ^bb3
92 ! CHECK: ^bb2:
93 ! CHECK: %[[VAL_44:.*]] = fir.emboxchar %[[VAL_38]]#0, %[[VAL_38]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
94 ! CHECK: %[[VAL_45:.*]] = arith.addi %[[VAL_41]], %[[VAL_37]] : index
95 ! CHECK: %[[VAL_46:.*]] = fir.array_coor %[[VAL_47]](%[[VAL_40]]) %[[VAL_45]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
96 ! CHECK: %[[VAL_48:.*]] = fir.call @_QPelem2(%[[VAL_44]], %[[VAL_46]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
97 ! CHECK: %[[VAL_49:.*]] = fir.array_coor %[[VAL_50]](%[[VAL_40]]) %[[VAL_45]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
98 ! CHECK: fir.store %[[VAL_48]] to %[[VAL_49]] : !fir.ref<i32>
99 ! CHECK: %[[VAL_51:.*]] = arith.subi %[[VAL_42]], %[[VAL_37]] : index
100 ! CHECK: br ^bb1(%[[VAL_45]], %[[VAL_51]] : index, index)
101 ! CHECK: ^bb3:
102 ! CHECK: return
103 integer :: i(10), j(10)
104 character(*) :: c
105 i = elem2(c, j)
106 end subroutine
108 ! CHECK-LABEL: func.func @_QMchar_elemPfoo2b(
109 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_1:.*]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_2:.*]]: !fir.boxchar<1>{{.*}}) {
110 subroutine foo2b(i, j, c)
111 integer :: i(10), j(10)
112 character(10) :: c
113 ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 10 : index
114 ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant 0 : index
115 ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 1 : index
116 ! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
117 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,10>>
118 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_3]] : (index) -> !fir.shape<1>
119 ! CHECK: cf.br ^bb1(%[[VAL_4]], %[[VAL_3]] : index, index)
120 ! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
121 ! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_4]] : index
122 ! CHECK: cf.cond_br %[[VAL_11]], ^bb2, ^bb3
123 ! CHECK: ^bb2:
124 ! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_7]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.char<1,?>>
125 ! CHECK: %[[VAL_13:.*]] = fir.emboxchar %[[VAL_12]], %[[VAL_3]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
126 ! CHECK: %[[VAL_14:.*]] = arith.addi %[[VAL_9]], %[[VAL_5]] : index
127 ! CHECK: %[[VAL_15:.*]] = fir.array_coor %[[VAL_1]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
128 ! CHECK: %[[VAL_16:.*]] = fir.call @_QPelem2(%[[VAL_13]], %[[VAL_15]]) fastmath<contract> : (!fir.boxchar<1>, !fir.ref<i32>) -> i32
129 ! CHECK: %[[VAL_17:.*]] = fir.array_coor %[[VAL_0]](%[[VAL_8]]) %[[VAL_14]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
130 ! CHECK: fir.store %[[VAL_16]] to %[[VAL_17]] : !fir.ref<i32>
131 ! CHECK: %[[VAL_18:.*]] = arith.subi %[[VAL_10]], %[[VAL_5]] : index
132 ! CHECK: cf.br ^bb1(%[[VAL_14]], %[[VAL_18]] : index, index)
133 ! CHECK: ^bb3:
134 ! CHECK: return
135 ! CHECK: }
136 i = elem2(c, j)
137 end subroutine
139 ! CHECK-LABEL: func @_QMchar_elemPfoo3(
140 ! CHECK-SAME: %[[VAL_88:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_79:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}})
141 subroutine foo3(i, j)
142 integer :: i(10), j(10)
143 ! CHECK-DAG: %[[VAL_69:.*]] = arith.constant 10 : index
144 ! CHECK-DAG: %[[VAL_70:.*]] = arith.constant 0 : index
145 ! CHECK-DAG: %[[VAL_71:.*]] = arith.constant 1 : index
146 ! CHECK-DAG: %[[VAL_72:.*]] = fir.alloca !fir.char<1>
147 ! CHECK: %[[VAL_73:.*]] = fir.shape %[[VAL_69]] : (index) -> !fir.shape<1>
148 ! CHECK: br ^bb1(%[[VAL_70]], %[[VAL_69]] : index, index)
149 ! CHECK: ^bb1(%[[VAL_74:.*]]: index, %[[VAL_75:.*]]: index):
150 ! CHECK: %[[VAL_76:.*]] = arith.cmpi sgt, %[[VAL_75]], %[[VAL_70]] : index
151 ! CHECK: cond_br %[[VAL_76]], ^bb2, ^bb3
152 ! CHECK: ^bb2:
153 ! CHECK: %[[VAL_77:.*]] = arith.addi %[[VAL_74]], %[[VAL_71]] : index
154 ! CHECK: %[[VAL_78:.*]] = fir.array_coor %[[VAL_79]](%[[VAL_73]]) %[[VAL_77]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
155 ! CHECK: %[[VAL_80:.*]] = fir.load %[[VAL_78]] : !fir.ref<i32>
156 ! CHECK: %[[VAL_81:.*]] = fir.convert %[[VAL_80]] : (i32) -> i8
157 ! CHECK: %[[VAL_82:.*]] = fir.undefined !fir.char<1>
158 ! CHECK: %[[VAL_83:.*]] = fir.insert_value %[[VAL_82]], %[[VAL_81]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
159 ! CHECK: fir.store %[[VAL_83]] to %[[VAL_72]] : !fir.ref<!fir.char<1>>
160 ! CHECK: %[[VAL_84:.*]] = fir.convert %[[VAL_72]] : (!fir.ref<!fir.char<1>>) -> !fir.ref<!fir.char<1,?>>
161 ! CHECK: %[[VAL_85:.*]] = fir.emboxchar %[[VAL_84]], %[[VAL_71]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
162 ! CHECK: %[[VAL_86:.*]] = fir.call @_QPelem(%[[VAL_85]]) {{.*}}: (!fir.boxchar<1>) -> i32
163 ! CHECK: %[[VAL_87:.*]] = fir.array_coor %[[VAL_88]](%[[VAL_73]]) %[[VAL_77]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
164 ! CHECK: fir.store %[[VAL_86]] to %[[VAL_87]] : !fir.ref<i32>
165 ! CHECK: %[[VAL_89:.*]] = arith.subi %[[VAL_75]], %[[VAL_71]] : index
166 ! CHECK: br ^bb1(%[[VAL_77]], %[[VAL_89]] : index, index)
167 ! CHECK: ^bb3:
168 ! CHECK: return
169 i = elem(char(j))
170 end subroutine
172 ! CHECK-LABEL: func @_QMchar_elemPfoo4(
173 ! CHECK-SAME: %[[VAL_106:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}}, %[[VAL_103:[^:]+]]: !fir.ref<!fir.array<10xi32>>{{.*}})
174 subroutine foo4(i, j)
175 integer :: i(10), j(10)
176 ! CHECK-DAG: %[[VAL_90:.*]] = arith.constant 5 : index
177 ! CHECK-DAG: %[[VAL_91:.*]] = arith.constant 10 : index
178 ! CHECK-DAG: %[[VAL_92:.*]] = arith.constant 0 : index
179 ! CHECK-DAG: %[[VAL_93:.*]] = arith.constant 1 : index
180 ! CHECK: %[[VAL_94:.*]] = fir.shape %[[VAL_91]] : (index) -> !fir.shape<1>
181 ! CHECK: %[[VAL_95:.*]] = fir.address_of(@{{.*}}) : !fir.ref<!fir.char<1,5>>
182 ! CHECK: br ^bb1(%[[VAL_92]], %[[VAL_91]] : index, index)
183 ! CHECK: ^bb1(%[[VAL_96:.*]]: index, %[[VAL_97:.*]]: index):
184 ! CHECK: %[[VAL_98:.*]] = arith.cmpi sgt, %[[VAL_97]], %[[VAL_92]] : index
185 ! CHECK: cond_br %[[VAL_98]], ^bb2, ^bb3
186 ! CHECK: ^bb2:
187 ! CHECK: %[[VAL_99:.*]] = fir.convert %[[VAL_95]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<!fir.char<1,?>>
188 ! CHECK: %[[VAL_100:.*]] = fir.emboxchar %[[VAL_99]], %[[VAL_90]] : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
189 ! CHECK: %[[VAL_101:.*]] = arith.addi %[[VAL_96]], %[[VAL_93]] : index
190 ! CHECK: %[[VAL_102:.*]] = fir.array_coor %[[VAL_103]](%[[VAL_94]]) %[[VAL_101]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
191 ! CHECK: %[[VAL_104:.*]] = fir.call @_QPelem2(%[[VAL_100]], %[[VAL_102]]) {{.*}}: (!fir.boxchar<1>, !fir.ref<i32>) -> i32
192 ! CHECK: %[[VAL_105:.*]] = fir.array_coor %[[VAL_106]](%[[VAL_94]]) %[[VAL_101]] : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
193 ! CHECK: fir.store %[[VAL_104]] to %[[VAL_105]] : !fir.ref<i32>
194 ! CHECK: %[[VAL_107:.*]] = arith.subi %[[VAL_97]], %[[VAL_93]] : index
195 ! CHECK: br ^bb1(%[[VAL_101]], %[[VAL_107]] : index, index)
196 ! CHECK: ^bb3:
197 ! CHECK: return
198 i = elem2("hello", j)
199 end subroutine
201 ! Test character return for elemental functions.
203 ! CHECK-LABEL: func @_QMchar_elemPelem_return_char(
204 ! CHECK-SAME: %{{.*}}: !fir.ref<!fir.char<1,?>>{{.*}}, %{{.*}}: index{{.*}}, %{{.*}}: !fir.boxchar<1>{{.*}}) -> !fir.boxchar<1>
205 elemental function elem_return_char(c)
206 character(*), intent(in) :: c
207 character(len(c)) :: elem_return_char
208 elem_return_char = "ab" // c
209 end function
211 ! CHECK-LABEL: func @_QMchar_elemPfoo6(
212 ! CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
213 subroutine foo6(c)
214 ! CHECK-DAG: %[[VAL_1:.*]] = arith.constant 10 : index
215 ! CHECK-DAG: %[[VAL_2:.*]] = arith.constant 1 : index
216 ! CHECK-DAG: %[[VAL_3:.*]] = arith.constant 0 : index
217 ! CHECK-DAG: %[[VAL_4:.*]] = arith.constant false
218 ! CHECK-DAG: %[[VAL_5:.*]] = arith.constant 32 : i8
219 ! CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
220 ! CHECK: %[[VAL_7:.*]] = fir.convert %[[VAL_6]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<10x!fir.char<1,?>>>
221 ! CHECK: %[[VAL_8:.*]] = fir.shape %[[VAL_1]] : (index) -> !fir.shape<1>
222 ! CHECK: br ^bb1(%[[VAL_3]], %[[VAL_1]] : index, index)
223 ! CHECK: ^bb1(%[[VAL_9:.*]]: index, %[[VAL_10:.*]]: index):
224 ! CHECK: %[[VAL_11:.*]] = arith.cmpi sgt, %[[VAL_10]], %[[VAL_3]] : index
225 ! CHECK: cond_br %[[VAL_11]], ^bb2, ^bb6
226 ! CHECK: ^bb2:
227 ! CHECK: %[[VAL_12:.*]] = arith.addi %[[VAL_9]], %[[VAL_2]] : index
228 ! 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,?>>
229 ! CHECK: %[[VAL_14:.*]] = fir.emboxchar %[[VAL_13]], %[[VAL_6]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
230 ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_6]]#1 : (index) -> i32
231 ! CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_15]] : (i32) -> index
232 ! CHECK: %[[CMPI:.*]] = arith.cmpi sgt, %[[VAL_16]], %{{.*}} : index
233 ! CHECK: %[[SELECT:.*]] = arith.select %[[CMPI]], %[[VAL_16]], %{{.*}} : index
234 ! CHECK: %[[VAL_17:.*]] = fir.call @llvm.stacksave.p0() {{.*}}: () -> !fir.ref<i8>
235 ! CHECK: %[[VAL_18:.*]] = fir.alloca !fir.char<1,?>(%[[SELECT]] : index) {bindc_name = ".result"}
236 ! 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>
237 ! CHECK: %[[VAL_20:.*]] = arith.cmpi slt, %[[VAL_6]]#1, %[[SELECT]] : index
238 ! CHECK: %[[VAL_21:.*]] = arith.select %[[VAL_20]], %[[VAL_6]]#1, %[[SELECT]] : index
239 ! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (index) -> i64
240 ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
241 ! CHECK: %[[VAL_24:.*]] = fir.convert %[[VAL_18]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
242 ! CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_23]], %[[VAL_24]], %[[VAL_22]], %[[VAL_4]]) {{.*}}: (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
243 ! CHECK: %[[VAL_25:.*]] = arith.subi %[[VAL_6]]#1, %[[VAL_2]] : index
244 ! CHECK: %[[VAL_26:.*]] = fir.undefined !fir.char<1>
245 ! CHECK: %[[VAL_27:.*]] = fir.insert_value %[[VAL_26]], %[[VAL_5]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
246 ! CHECK: %[[VAL_28:.*]] = arith.subi %[[VAL_25]], %[[VAL_21]] : index
247 ! CHECK: %[[VAL_29:.*]] = arith.addi %[[VAL_28]], %[[VAL_2]] : index
248 ! CHECK: br ^bb3(%[[VAL_21]], %[[VAL_29]] : index, index)
249 ! CHECK: ^bb3(%[[VAL_30:.*]]: index, %[[VAL_31:.*]]: index):
250 ! CHECK: %[[VAL_32:.*]] = arith.cmpi sgt, %[[VAL_31]], %[[VAL_3]] : index
251 ! CHECK: cond_br %[[VAL_32]], ^bb4, ^bb5
252 ! CHECK: ^bb4:
253 ! CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
254 ! CHECK: %[[VAL_34:.*]] = fir.coordinate_of %[[VAL_33]], %[[VAL_30]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
255 ! CHECK: fir.store %[[VAL_27]] to %[[VAL_34]] : !fir.ref<!fir.char<1>>
256 ! CHECK: %[[VAL_35:.*]] = arith.addi %[[VAL_30]], %[[VAL_2]] : index
257 ! CHECK: %[[VAL_36:.*]] = arith.subi %[[VAL_31]], %[[VAL_2]] : index
258 ! CHECK: br ^bb3(%[[VAL_35]], %[[VAL_36]] : index, index)
259 ! CHECK: ^bb5:
260 ! CHECK: fir.call @llvm.stackrestore.p0(%[[VAL_17]]) {{.*}}: (!fir.ref<i8>) -> ()
261 ! CHECK: %[[VAL_37:.*]] = arith.subi %[[VAL_10]], %[[VAL_2]] : index
262 ! CHECK: br ^bb1(%[[VAL_12]], %[[VAL_37]] : index, index)
263 ! CHECK: ^bb6:
265 implicit none
266 character(*) :: c(10)
267 c = elem_return_char(c)
268 ! CHECK: return
269 ! CHECK: }
270 end subroutine
272 end module