1 // Test hlfir.count operation parse, verify (no errors), and unparse
3 // RUN: fir-opt %s | fir-opt | FileCheck %s
5 // mask is an expression of known shape
6 func.func @count0(%arg0: !hlfir.expr<2x!fir.logical<4>>) {
7 %count = hlfir.count %arg0 : (!hlfir.expr<2x!fir.logical<4>>) -> i32
10 // CHECK: func.func @count0(%[[ARRAY:.*]]: !hlfir.expr<2x!fir.logical<4>>) {
11 // CHECK-NEXT: %[[COUNT:.*]] = hlfir.count %[[ARRAY]] : (!hlfir.expr<2x!fir.logical<4>>) -> i32
15 // mask is an expression of assumed shape
16 func.func @count1(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
17 %count = hlfir.count %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> i32
20 // CHECK: func.func @count1(%[[ARRAY:.*]]: !hlfir.expr<?x!fir.logical<4>>) {
21 // CHECK-NEXT: %[[COUNT:.*]] = hlfir.count %[[ARRAY]] : (!hlfir.expr<?x!fir.logical<4>>) -> i32
25 // mask is a boxed array
26 func.func @count2(%arg0: !fir.box<!fir.array<2x!fir.logical<4>>>) {
27 %count = hlfir.count %arg0 : (!fir.box<!fir.array<2x!fir.logical<4>>>) -> i32
30 // CHECK: func.func @count2(%[[ARRAY:.*]]: !fir.box<!fir.array<2x!fir.logical<4>>>) {
31 // CHECK-NEXT: %[[COUNT:.*]] = hlfir.count %[[ARRAY]] : (!fir.box<!fir.array<2x!fir.logical<4>>>) -> i32
35 // mask is an assumed shape boxed array
36 func.func @count3(%arg0: !fir.box<!fir.array<?x!fir.logical<4>>>) {
37 %count = hlfir.count %arg0 : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
40 // CHECK: func.func @count3(%[[ARRAY:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>) {
41 // CHECK-NEXT: %[[COUNT:.*]] = hlfir.count %[[ARRAY]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> i32
45 // mask is a 2-dimensional array
46 func.func @count4(%arg0: !fir.box<!fir.array<?x?x!fir.logical<4>>>){
47 %count = hlfir.count %arg0 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> i32
50 // CHECK: func.func @count4(%[[ARRAY:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>) {
51 // CHECK-NEXT: %[[COUNT:.*]] = hlfir.count %[[ARRAY]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>) -> i32
55 // mask and dim argument
56 func.func @count5(%arg0: !fir.box<!fir.array<?x!fir.logical<4>>>, %arg1: i32) {
57 %count = hlfir.count %arg0 dim %arg1 : (!fir.box<!fir.array<?x!fir.logical<4>>>, i32) -> i32
60 // CHECK: func.func @count5(%[[ARRAY:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>, %[[DIM:.*]]: i32) {
61 // CHECK-NEXT: %[[COUNT:.*]] = hlfir.count %[[ARRAY]] dim %[[DIM]] : (!fir.box<!fir.array<?x!fir.logical<4>>>, i32) -> i32
65 // mask is a 2 dimensional array with dim
66 func.func @count6(%arg0: !fir.box<!fir.array<?x?x!fir.logical<4>>>, %arg1: i32) {
67 %count = hlfir.count %arg0 dim %arg1 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i32) -> i32
70 // CHECK: func.func @count6(%[[ARRAY:.*]]: !fir.box<!fir.array<?x?x!fir.logical<4>>>, %[[DIM:.*]]: i32) {
71 // CHECK-NEXT: %[[ANY:.*]] = hlfir.count %[[ARRAY]] dim %[[DIM]] : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i32) -> i32
75 // mask is of a different logical type
76 func.func @count7(%arg0: !fir.box<!fir.array<?x?x!fir.logical<8>>>, %arg1: i32) {
77 %count = hlfir.count %arg0 dim %arg1 : (!fir.box<!fir.array<?x?x!fir.logical<8>>>, i32) -> i32
80 // CHECK: func.func @count7(%[[ARRAY:.*]]: !fir.box<!fir.array<?x?x!fir.logical<8>>>, %[[DIM:.*]]: i32) {
81 // CHECK-NEXT: %[[ANY:.*]] = hlfir.count %[[ARRAY]] dim %[[DIM]] : (!fir.box<!fir.array<?x?x!fir.logical<8>>>, i32) -> i32