1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 ! CHECK-LABEL: count_test1
4 ! CHECK-SAME: %[[arg0:.*]]: !fir.ref<i32>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>{{.*}})
5 subroutine count_test1(rslt
, mask
)
8 ! CHECK-DAG: %[[c1:.*]] = arith.constant 0 : index
9 ! CHECK-DAG: %[[a2:.*]] = fir.convert %[[arg1]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
10 ! CHECK: %[[a4:.*]] = fir.convert %[[c1]] : (index) -> i32
12 ! CHECK: %[[a5:.*]] = fir.call @_FortranACount(%[[a2]], %{{.*}}, %{{.*}}, %[[a4]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32) -> i64
15 ! CHECK-LABEL: test_count2
16 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>{{.*}})
17 subroutine test_count2(rslt
, mask
)
20 ! CHECK-DAG: %[[c1_i32:.*]] = arith.constant 1 : i32
21 ! CHECK-DAG: %[[c4:.*]] = arith.constant 4 : index
22 ! CHECK-DAG: %[[a0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
23 ! CHECK: %[[a5:.*]] = fir.convert %[[a0]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
24 ! CHECK: %[[a6:.*]] = fir.convert %[[arg1]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> !fir.box<none>
25 ! CHECK: %[[a7:.*]] = fir.convert %[[c4]] : (index) -> i32
26 rslt
= count(mask
, dim
=1)
27 ! CHECK: %{{.*}} = fir.call @_FortranACountDim(%[[a5]], %[[a6]], %[[c1_i32]], %[[a7]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32) -> none
28 ! CHECK: %[[a10:.*]] = fir.load %[[a0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
29 ! CHECK: %[[a12:.*]] = fir.box_addr %[[a10]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
30 ! CHECK: fir.freemem %[[a12]]
33 ! CHECK-LABEL: test_count3
34 ! CHECK-SAME: %[[arg0:.*]]: !fir.ref<i32>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>{{.*}})
35 subroutine test_count3(rslt
, mask
)
38 ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
39 ! CHECK-DAG: %[[a1:.*]] = fir.convert %[[arg1]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
40 ! CHECK: %[[a3:.*]] = fir.convert %[[c0]] : (index) -> i32
41 call bar(count(mask
, kind
=2))
42 ! CHECK: %[[a4:.*]] = fir.call @_FortranACount(%[[a1]], %{{.*}}, %{{.*}}, %[[a3]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32) -> i64
43 ! CHECK: %{{.*}} = fir.convert %[[a4]] : (i64) -> i16