[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / Intrinsics / shiftl.f90
blob92414c2f7a92e152b2dee245dac78767d670887d
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: shiftl1_test
5 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i8>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<i8>{{.*}}
6 subroutine shiftl1_test(a, b, c)
7 integer(kind=1) :: a
8 integer :: b
9 integer(kind=1) :: c
11 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i8>
12 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
13 c = shiftl(a, b)
14 ! CHECK: %[[C_BITS:.*]] = arith.constant 8 : i8
15 ! CHECK: %[[C_0:.*]] = arith.constant 0 : i8
16 ! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i8
17 ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i8
18 ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i8
19 ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
20 ! CHECK: %[[SHIFT:.*]] = arith.shli %[[A_VAL]], %[[B_CONV]] : i8
21 ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i8
22 end subroutine shiftl1_test
24 ! CHECK-LABEL: shiftl2_test
25 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i16>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<i16>{{.*}}
26 subroutine shiftl2_test(a, b, c)
27 integer(kind=2) :: a
28 integer :: b
29 integer(kind=2) :: c
31 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i16>
32 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
33 c = shiftl(a, b)
34 ! CHECK: %[[C_BITS:.*]] = arith.constant 16 : i16
35 ! CHECK: %[[C_0:.*]] = arith.constant 0 : i16
36 ! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i16
37 ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i16
38 ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i16
39 ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
40 ! CHECK: %[[SHIFT:.*]] = arith.shli %[[A_VAL]], %[[B_CONV]] : i16
41 ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i16
42 end subroutine shiftl2_test
44 ! CHECK-LABEL: shiftl4_test
45 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i32>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<i32>{{.*}}
46 subroutine shiftl4_test(a, b, c)
47 integer(kind=4) :: a
48 integer :: b
49 integer(kind=4) :: c
51 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
52 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
53 c = shiftl(a, b)
54 ! CHECK: %[[C_BITS:.*]] = arith.constant 32 : i32
55 ! CHECK: %[[C_0:.*]] = arith.constant 0 : i32
56 ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_VAL]], %[[C_0]] : i32
57 ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_VAL]], %[[C_BITS]] : i32
58 ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
59 ! CHECK: %[[SHIFT:.*]] = arith.shli %[[A_VAL]], %[[B_VAL]] : i32
60 ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i32
61 end subroutine shiftl4_test
63 ! CHECK-LABEL: shiftl8_test
64 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i64>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<i64>{{.*}}
65 subroutine shiftl8_test(a, b, c)
66 integer(kind=8) :: a
67 integer :: b
68 integer(kind=8) :: c
70 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i64>
71 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
72 c = shiftl(a, b)
73 ! CHECK: %[[C_BITS:.*]] = arith.constant 64 : i64
74 ! CHECK: %[[C_0:.*]] = arith.constant 0 : i64
75 ! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i64
76 ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i64
77 ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i64
78 ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
79 ! CHECK: %[[SHIFT:.*]] = arith.shli %[[A_VAL]], %[[B_CONV]] : i64
80 ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i64
81 end subroutine shiftl8_test
83 ! CHECK-LABEL: shiftl16_test
84 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i128>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<i128>{{.*}}
85 subroutine shiftl16_test(a, b, c)
86 integer(kind=16) :: a
87 integer :: b
88 integer(kind=16) :: c
90 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i128>
91 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
92 c = shiftl(a, b)
93 ! CHECK: %[[C_BITS:.*]] = arith.constant 128 : i128
94 ! CHECK: %[[C_0:.*]] = arith.constant 0 : i128
95 ! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i128
96 ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i128
97 ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i128
98 ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
99 ! CHECK: %[[SHIFT:.*]] = arith.shli %[[A_VAL]], %[[B_CONV]] : i128
100 ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i128
101 end subroutine shiftl16_test