Revert "[InstCombine] Support gep nuw in icmp folds" (#118698)
[llvm-project.git] / flang / test / Lower / Intrinsics / leadz.f90
blob181a8fdc4a4b1876587c09b79b5f251af80c6399
1 ! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
4 ! CHECK-LABEL: leadz1_test
5 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i8>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
6 subroutine leadz1_test(a, b)
7 integer(1) :: a
8 integer :: b
10 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i8>
11 b = leadz(a)
12 ! CHECK: %[[COUNT:.*]] = math.ctlz %[[AVAL]] : i8
13 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i8) -> i32
14 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
15 end subroutine leadz1_test
17 ! CHECK-LABEL: leadz2_test
18 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i16>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
19 subroutine leadz2_test(a, b)
20 integer(2) :: a
21 integer :: b
23 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i16>
24 b = leadz(a)
25 ! CHECK: %[[COUNT:.*]] = math.ctlz %[[AVAL]] : i16
26 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i16) -> i32
27 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
28 end subroutine leadz2_test
30 ! CHECK-LABEL: leadz4_test
31 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i32>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
32 subroutine leadz4_test(a, b)
33 integer(4) :: a
34 integer :: b
36 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i32>
37 b = leadz(a)
38 ! CHECK: %[[RESULT:.*]] = math.ctlz %[[AVAL]] : i32
39 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
40 end subroutine leadz4_test
42 ! CHECK-LABEL: leadz8_test
43 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i64>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
44 subroutine leadz8_test(a, b)
45 integer(8) :: a
46 integer :: b
48 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i64>
49 b = leadz(a)
50 ! CHECK: %[[COUNT:.*]] = math.ctlz %[[AVAL]] : i64
51 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i64) -> i32
52 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
53 end subroutine leadz8_test
55 ! CHECK-LABEL: leadz16_test
56 ! CHECK-SAME: %[[AREF:.*]]: !fir.ref<i128>{{.*}}, %[[BREF:.*]]: !fir.ref<i32>{{.*}}
57 subroutine leadz16_test(a, b)
58 integer(16) :: a
59 integer :: b
61 ! CHECK: %[[AVAL:.*]] = fir.load %[[AREF]] : !fir.ref<i128>
62 b = leadz(a)
63 ! CHECK: %[[COUNT:.*]] = math.ctlz %[[AVAL]] : i128
64 ! CHECK: %[[RESULT:.*]] = fir.convert %[[COUNT]] : (i128) -> i32
65 ! CHECK: fir.store %[[RESULT]] to %[[BREF]] : !fir.ref<i32>
66 end subroutine leadz16_test