[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / HLFIR / conversion-ops.f90
blob230d74ea9a00e0eb6ce890038617c5eb1f504ee8
1 ! Test lowering of intrinsic conversions to HLFIR
2 ! RUN: bbc -emit-fir -hlfir -o - %s 2>&1 | FileCheck %s
4 subroutine test
5 integer(4) :: i4
6 integer(8) :: i8
7 real(4) :: r4
8 real(8) :: r8
9 complex(4) :: z4
10 complex(8) :: z8
12 logical(4) :: l4
13 logical(8) :: l8
15 i4 = i8
16 ! CHECK: fir.convert %{{.*}} : (i64) -> i32
17 i4 = r4
18 ! CHECK: fir.convert %{{.*}} : (f32) -> i32
19 i4 = r8
20 ! CHECK: fir.convert %{{.*}} : (f64) -> i32
21 i4 = z4
22 ! CHECK: %[[VAL_23:.*]] = fir.extract_value %{{.*}}, [0 : index] : (!fir.complex<4>) -> f32
23 ! CHECK: fir.convert %[[VAL_23]] : (f32) -> i32
24 i4 = z8
25 ! CHECK: %[[VAL_26:.*]] = fir.extract_value %{{.*}}, [0 : index] : (!fir.complex<8>) -> f64
26 ! CHECK: fir.convert %[[VAL_26]] : (f64) -> i32
28 r4 = i4
29 ! CHECK: fir.convert %{{.*}} : (i32) -> f32
30 r4 = i8
31 ! CHECK: fir.convert %{{.*}} : (i64) -> f32
32 r4 = r8
33 ! CHECK: fir.convert %{{.*}} : (f64) -> f32
34 r4 = z4
35 ! CHECK: fir.extract_value %{{.*}}, [0 : index] : (!fir.complex<4>) -> f32
36 r4 = z8
37 ! CHECK: %[[VAL_36:.*]] = fir.load %{{.*}} : !fir.ref<!fir.complex<8>>
38 ! CHECK: %[[VAL_37:.*]] = fir.extract_value %[[VAL_36]], [0 : index] : (!fir.complex<8>) -> f64
39 ! CHECK: fir.convert %[[VAL_37]] : (f64) -> f32
41 z4 = i4
42 ! CHECK: %[[VAL_40:.*]] = fir.convert %{{.*}} : (i32) -> f32
43 ! CHECK: %[[VAL_41:.*]] = arith.constant 0.000000e+00 : f32
44 ! CHECK: %[[VAL_42:.*]] = fir.undefined !fir.complex<4>
45 ! CHECK: %[[VAL_43:.*]] = fir.insert_value %[[VAL_42]], %[[VAL_40]], [0 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
46 ! CHECK: fir.insert_value %[[VAL_43]], %[[VAL_41]], [1 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
47 z4 = i8
48 ! CHECK: %[[VAL_46:.*]] = fir.convert %{{.*}} : (i64) -> f32
49 ! CHECK: %[[VAL_47:.*]] = arith.constant 0.000000e+00 : f32
50 ! CHECK: %[[VAL_48:.*]] = fir.undefined !fir.complex<4>
51 ! CHECK: %[[VAL_49:.*]] = fir.insert_value %[[VAL_48]], %[[VAL_46]], [0 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
52 ! CHECK: fir.insert_value %[[VAL_49]], %[[VAL_47]], [1 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
53 z4 = r4
54 ! CHECK: %[[VAL_52:.*]] = arith.constant 0.000000e+00 : f32
55 ! CHECK: %[[VAL_53:.*]] = fir.undefined !fir.complex<4>
56 ! CHECK: %[[VAL_54:.*]] = fir.insert_value %[[VAL_53]], %{{.*}}, [0 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
57 ! CHECK: fir.insert_value %[[VAL_54]], %[[VAL_52]], [1 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
58 z4 = r8
59 ! CHECK: %[[VAL_57:.*]] = fir.convert %{{.*}} : (f64) -> f32
60 ! CHECK: %[[VAL_58:.*]] = arith.constant 0.000000e+00 : f32
61 ! CHECK: %[[VAL_59:.*]] = fir.undefined !fir.complex<4>
62 ! CHECK: %[[VAL_60:.*]] = fir.insert_value %[[VAL_59]], %[[VAL_57]], [0 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
63 ! CHECK: fir.insert_value %[[VAL_60]], %[[VAL_58]], [1 : index] : (!fir.complex<4>, f32) -> !fir.complex<4>
64 z4 = z8
65 ! CHECK: fir.convert %{{.*}} : (!fir.complex<8>) -> !fir.complex<4>
67 l4 = l8
68 ! CHECK: fir.convert %{{.*}} : (!fir.logical<8>) -> !fir.logical<4>
69 end subroutine