1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: func @_QPfindloc_test_1d(
5 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}) -> !fir.array<1xi32>
6 function findloc_test_1d(a
, v
)
9 integer, dimension(1) :: findloc_test_1d
10 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
11 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
12 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
13 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
14 ! CHECK-DAG: %[[false:.*]] = arith.constant false
15 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
16 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
17 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
18 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
19 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
20 findloc_test_1d
= findloc(a
, v
)
21 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
22 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
23 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
24 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
25 end function findloc_test_1d
27 ! CHECK-LABEL: func @_QPfindloc_test_2d(
28 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}) -> !fir.array<2xi32>
29 function findloc_test_2d(a
, v
)
32 integer, dimension(2) :: findloc_test_2d
33 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
34 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
35 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
36 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
37 ! CHECK-DAG: %[[false:.*]] = arith.constant false
38 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
39 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
40 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
41 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
42 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
43 findloc_test_2d
= findloc(a
, v
)
44 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
45 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
46 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
47 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
48 end function findloc_test_2d
50 ! CHECK-LABEL: func @_QPfindloc_test_byval(
51 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: i32{{.*}}) -> !fir.array<2xi32>
52 function findloc_test_byval(a
, v
)
55 integer, dimension(2) :: findloc_test_byval
56 ! CHECK-DAG: %[[a1:.*]] = fir.alloca i32
57 ! CHECK-DAG: fir.store %[[arg1]] to %[[a1]] : !fir.ref<i32>
58 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
59 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[a1]] : (!fir.ref<i32>) -> !fir.box<i32>
60 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
61 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
62 ! CHECK-DAG: %[[false:.*]] = arith.constant false
63 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
64 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
65 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
66 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
67 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
68 findloc_test_byval
= findloc(a
, v
)
69 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
70 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
71 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
72 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
73 end function findloc_test_byval
75 ! CHECK-LABEL: func @_QPfindloc_test_back_true(
76 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}) -> !fir.array<2xi32>
77 function findloc_test_back_true(a
, v
)
80 integer, dimension(2) :: findloc_test_back_true
81 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
82 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
83 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
84 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
85 ! CHECK-DAG: %[[true:.*]] = arith.constant true
86 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
87 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
88 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
89 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
90 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
91 findloc_test_back_true
= findloc(a
, v
, back
=.true
.)
92 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %true) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
93 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
94 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
95 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
96 end function findloc_test_back_true
98 ! CHECK-LABEL: func @_QPfindloc_test_back(
99 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}, %[[arg2:.*]]: !fir.ref<!fir.logical<4>>{{.*}}) -> !fir.array<2xi32>
100 function findloc_test_back(a
, v
, back
)
104 integer, dimension(2) :: findloc_test_back
105 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
106 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
107 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
108 ! CHECK-DAG: %[[b:.*]] = fir.load %[[arg2]] : !fir.ref<!fir.logical<4>>
109 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
110 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
111 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
112 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
113 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
114 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
115 ! CHECK-DAG: %[[back:.*]] = fir.convert %[[b]] : (!fir.logical<4>) -> i1
116 findloc_test_back
= findloc(a
, v
, back
=back
)
117 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %[[back]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
118 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
119 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
120 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
121 end function findloc_test_back
123 ! CHECK-LABEL: func @_QPfindloc_test_dim(
124 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}, %[[arg2:.*]]: !fir.box<!fir.array<?xi32>>{{.*}})
125 subroutine findloc_test_dim(a
, v
, res
)
129 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
130 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
131 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
132 ! CHECK-DAG: %[[c1:.*]] = arith.constant 1 : i32
133 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
134 ! CHECK-DAG: %[[false:.*]] = arith.constant false
135 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
136 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
137 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
138 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
139 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
140 res
= findloc(a
, v
, dim
=1)
141 ! CHECK: %{{.*}} = fir.call @_FortranAFindlocDim(%[[res]], %[[arr]], %[[val]], %[[kind]], %[[c1]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
142 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
143 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
144 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
145 end subroutine findloc_test_dim
147 ! CHECK-LABEL: func @_QPfindloc_test_dim_unknown(
148 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}, %[[arg2:.*]]: !fir.ref<i32>{{.*}}, %[[arg3:.*]]: !fir.box<!fir.array<?xi32>>{{.*}})
149 subroutine findloc_test_dim_unknown(a
, v
, dim
, res
)
154 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
155 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
156 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
157 ! CHECK-DAG: %[[dim:.*]] = fir.load %[[arg2]] : !fir.ref<i32>
158 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
159 ! CHECK-DAG: %[[false:.*]] = arith.constant false
160 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
161 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
162 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
163 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
164 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
165 res
= findloc(a
, v
, dim
=dim
)
166 ! CHECK: %{{.*}} = fir.call @_FortranAFindlocDim(%[[res]], %[[arr]], %[[val]], %[[kind]], %[[dim]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
167 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
168 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
169 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
170 end subroutine findloc_test_dim_unknown
172 ! CHECK-LABEL: func @_QPfindloc_test_kind(
173 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}, %[[arg2:.*]]: !fir.box<!fir.array<?xi64>>{{.*}})
174 subroutine findloc_test_kind(a
, v
, res
)
178 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi64>>>
179 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
180 ! CHECK-DAG: %[[m:.*]] = fir.absent !fir.box<i1>
181 ! CHECK-DAG: %[[kind:.*]] = arith.constant 8 : i32
182 ! CHECK-DAG: %[[false:.*]] = arith.constant false
183 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi64>>>>) -> !fir.ref<!fir.box<none>>
184 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
185 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
186 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<i1>) -> !fir.box<none>
187 res
= findloc(a
, v
, kind
=8)
188 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
189 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi64>>>>
190 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi64>>>) -> !fir.heap<!fir.array<?xi64>>
191 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi64>>
192 end subroutine findloc_test_kind
194 ! CHECK-LABEL: func @_QPfindloc_test_non_scalar_mask(
195 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}, %[[arg2:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>{{.*}}
196 subroutine findloc_test_non_scalar_mask(a
, v
, mask
, res
)
201 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
202 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
203 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
204 ! CHECK-DAG: %[[false:.*]] = arith.constant false
205 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
206 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
207 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
208 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[arg2]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !fir.box<none>
209 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
210 res
= findloc(a
, v
, mask
=mask
)
211 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
212 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
213 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
214 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
215 end subroutine findloc_test_non_scalar_mask
217 ! CHECK-LABEL: func @_QPfindloc_test_scalar_mask(
218 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}, %[[arg2:.*]]: !fir.ref<!fir.logical<4>>{{.*}}, %[[arg3:.*]]: !fir.box<!fir.array<?xi32>>{{.*}})
219 subroutine findloc_test_scalar_mask(a
, v
, mask
, res
)
224 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
225 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
226 ! CHECK-DAG: %[[m:.*]] = fir.embox %[[arg2]] : (!fir.ref<!fir.logical<4>>) -> !fir.box<!fir.logical<4>>
227 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
228 ! CHECK-DAG: %[[false:.*]] = arith.constant false
229 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
230 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
231 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
232 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[m]] : (!fir.box<!fir.logical<4>>) -> !fir.box<none>
233 ! CHECK-DAG: %[[kind:.*]] = fir.convert %[[c4]] : (index) -> i32
234 res
= findloc(a
, v
, mask
=mask
)
235 ! CHECK: %{{.*}} = fir.call @_FortranAFindloc(%[[res]], %[[arr]], %[[val]], %[[kind]], %{{.*}}, %{{.*}}, %[[mask]], %false) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
236 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
237 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
238 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi32>>
239 end subroutine findloc_test_scalar_mask
241 ! CHECK-LABEL: func @_QPfindloc_test_all(
242 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}, %[[arg2:.*]]: !fir.ref<i32>{{.*}}, %[[arg3:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>{{.*}}, %[[arg4:.*]]: !fir.ref<!fir.logical<4>>{{.*}}, %[[arg5:.*]]: !fir.box<!fir.array<?xi64>>{{.*}}
243 subroutine findloc_test_all(a
, v
, dim
, mask
, back
, res
)
250 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi64>>>
251 ! CHECK-DAG: %[[v:.*]] = fir.embox %[[arg1]] : (!fir.ref<i32>) -> !fir.box<i32>
252 ! CHECK-DAG: %[[b:.*]] = fir.load %[[arg4]] : !fir.ref<!fir.logical<4>>
253 ! CHECK-DAG: %[[kind:.*]] = arith.constant 8 : i32
254 ! CHECK-DAG: %[[dim:.*]] = fir.load %[[arg2]] : !fir.ref<i32>
255 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi64>>>>) -> !fir.ref<!fir.box<none>>
256 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
257 ! CHECK-DAG: %[[val:.*]] = fir.convert %[[v]] : (!fir.box<i32>) -> !fir.box<none>
258 ! CHECK-DAG: %[[mask:.*]] = fir.convert %[[arg3]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !fir.box<none>
259 ! CHECK-DAG: %[[back:.*]] = fir.convert %[[b]] : (!fir.logical<4>) -> i1
260 res
= findloc(a
, v
, dim
=dim
, mask
=mask
, kind
=8, back
=back
)
261 ! CHECK: %{{.*}} = fir.call @_FortranAFindlocDim(%[[res]], %[[arr]], %[[val]], %[[kind]], %[[dim]], %{{.*}}, %{{.*}}, %[[mask]], %[[back]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32, !fir.box<none>, i1) -> none
262 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi64>>>>
263 ! CHECK: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xi64>>>) -> !fir.heap<!fir.array<?xi64>>
264 ! CHECK: fir.freemem %[[addr]] : !fir.heap<!fir.array<?xi64>>
265 end subroutine findloc_test_all