[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / Intrinsics / popcnt.f90
blob7e5785db0de98d9c7791786acab67f464db3982d
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: popcnt1_test
5 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i8>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
6 subroutine popcnt1_test(a, b)
7 integer(1) :: a
8 integer :: b
10 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i8>
11 b = popcnt(a)
12 ! CHECK: %[[COUNT:.*]] = math.ctpop %[[AVAL]] : i8
13 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i8) -> i32
14 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
15 end subroutine popcnt1_test
17 ! CHECK-LABEL: popcnt2_test
18 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i16>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
19 subroutine popcnt2_test(a, b)
20 integer(2) :: a
21 integer :: b
23 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i16>
24 b = popcnt(a)
25 ! CHECK: %[[COUNT:.*]] = math.ctpop %[[AVAL]] : i16
26 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i16) -> i32
27 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
28 end subroutine popcnt2_test
30 ! CHECK-LABEL: popcnt4_test
31 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i32>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
32 subroutine popcnt4_test(a, b)
33 integer(4) :: a
34 integer :: b
36 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i32>
37 b = popcnt(a)
38 ! CHECK: %[[RESULT:.*]] = math.ctpop %[[AVAL]] : i32
39 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
40 end subroutine popcnt4_test
42 ! CHECK-LABEL: popcnt8_test
43 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i64>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
44 subroutine popcnt8_test(a, b)
45 integer(8) :: a
46 integer :: b
48 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i64>
49 b = popcnt(a)
50 ! CHECK: %[[COUNT:.*]] = math.ctpop %[[AVAL]] : i64
51 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i64) -> i32
52 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
53 end subroutine popcnt8_test
55 ! CHECK-LABEL: popcnt16_test
56 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i128>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
57 subroutine popcnt16_test(a, b)
58 integer(16) :: a
59 integer :: b
61 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i128>
62 b = popcnt(a)
63 ! CHECK: %[[COUNT:.*]] = math.ctpop %[[AVAL]] : i128
64 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i128) -> i32
65 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
66 end subroutine popcnt16_test