Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / Intrinsics / trailz.f90
blobdb05f3169e0ffe3043330892042cabe3b066d7b8
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: trailz1_test
5 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i8>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
6 subroutine trailz1_test(a, b)
7 integer(1) :: a
8 integer :: b
10 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i8>
11 b = trailz(a)
12 ! CHECK: %[[COUNT:.*]] = math.cttz %[[AVAL]] : i8
13 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i8) -> i32
14 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
15 end subroutine trailz1_test
17 ! CHECK-LABEL: trailz2_test
18 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i16>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
19 subroutine trailz2_test(a, b)
20 integer(2) :: a
21 integer :: b
23 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i16>
24 b = trailz(a)
25 ! CHECK: %[[COUNT:.*]] = math.cttz %[[AVAL]] : i16
26 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i16) -> i32
27 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
28 end subroutine trailz2_test
30 ! CHECK-LABEL: trailz4_test
31 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i32>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
32 subroutine trailz4_test(a, b)
33 integer(4) :: a
34 integer :: b
36 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i32>
37 b = trailz(a)
38 ! CHECK: %[[RESULT:.*]] = math.cttz %[[AVAL]] : i32
39 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
40 end subroutine trailz4_test
42 ! CHECK-LABEL: trailz8_test
43 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i64>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
44 subroutine trailz8_test(a, b)
45 integer(8) :: a
46 integer :: b
48 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i64>
49 b = trailz(a)
50 ! CHECK: %[[COUNT:.*]] = math.cttz %[[AVAL]] : i64
51 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i64) -> i32
52 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
53 end subroutine trailz8_test
55 ! CHECK-LABEL: trailz16_test
56 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i128>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
57 subroutine trailz16_test(a, b)
58 integer(16) :: a
59 integer :: b
61 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i128>
62 b = trailz(a)
63 ! CHECK: %[[COUNT:.*]] = math.cttz %[[AVAL]] : i128
64 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i128) -> i32
65 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
66 end subroutine trailz16_test