[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Lower / Intrinsics / norm2.f90
blob01c5ad50eed1e9d276e104bb36c4b1cace200138
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: func @_QPnorm2_test_4(
5 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xf32>>{{.*}}) -> f32
6 real(4) function norm2_test_4(a)
7 real(4) :: a(:)
8 ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
9 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
10 ! CHECK: %[[dim:.*]] = fir.convert %[[c0]] : (index) -> i32
11 norm2_test_4 = norm2(a)
12 ! CHECK: %{{.*}} = fir.call @_FortranANorm2_4(%[[arr]], %{{.*}}, %{{.*}}, %[[dim]]) {{.*}} : (!fir.box<none>, !fir.ref<i8>, i32, i32) -> f32
13 end function norm2_test_4
15 ! CHECK-LABEL: func @_QPnorm2_test_8(
16 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xf64>>{{.*}}) -> f64
17 real(8) function norm2_test_8(a)
18 real(8) :: a(:,:)
19 ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
20 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xf64>>) -> !fir.box<none>
21 ! CHECK: %[[dim:.*]] = fir.convert %[[c0]] : (index) -> i32
22 norm2_test_8 = norm2(a)
23 ! CHECK: %{{.*}} = fir.call @_FortranANorm2_8(%[[arr]], %{{.*}}, %{{.*}}, %[[dim]]) {{.*}} : (!fir.box<none>, !fir.ref<i8>, i32, i32) -> f64
24 end function norm2_test_8
26 ! CHECK-LABEL: func @_QPnorm2_test_10(
27 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?x?xf80>>{{.*}}) -> f80
28 real(10) function norm2_test_10(a)
29 real(10) :: a(:,:,:)
30 ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
31 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?x?xf80>>) -> !fir.box<none>
32 ! CHECK: %[[dim:.*]] = fir.convert %[[c0]] : (index) -> i32
33 norm2_test_10 = norm2(a)
34 ! CHECK: %{{.*}} = fir.call @_FortranANorm2_10(%[[arr]], %{{.*}}, %{{.*}}, %[[dim]]) {{.*}} : (!fir.box<none>, !fir.ref<i8>, i32, i32) -> f80
35 end function norm2_test_10
37 ! CHECK-LABEL: func @_QPnorm2_test_16(
38 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?x?xf128>>{{.*}}) -> f128
39 real(16) function norm2_test_16(a)
40 real(16) :: a(:,:,:)
41 ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
42 ! CHECK-DAG: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?x?xf128>>) -> !fir.box<none>
43 ! CHECK: %[[dim:.*]] = fir.convert %[[c0]] : (index) -> i32
44 norm2_test_16 = norm2(a)
45 ! CHECK: %{{.*}} = fir.call @_FortranANorm2_16(%[[arr]], %{{.*}}, %{{.*}}, %[[dim]]) {{.*}} : (!fir.box<none>, !fir.ref<i8>, i32, i32) -> f128
46 end function norm2_test_16
48 ! CHECK-LABEL: func @_QPnorm2_test_dim_2(
49 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?xf32>>{{.*}})
50 subroutine norm2_test_dim_2(a,r)
51 real :: a(:,:)
52 real :: r(:)
53 ! CHECK-DAG: %[[dim:.*]] = arith.constant 1 : i32
54 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xf32>>>
55 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>) -> !fir.ref<!fir.box<none>>
56 ! CHECK: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xf32>>) -> !fir.box<none>
57 r = norm2(a,dim=1)
58 ! CHECK: %{{.*}} = fir.call @_FortranANorm2Dim(%[[res]], %[[arr]], %[[dim]], %{{.*}}, %{{.*}}) {{.*}} : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, !fir.ref<i8>, i32) -> none
59 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xf32>>>>
60 ! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?xf32>>>) -> !fir.heap<!fir.array<?xf32>>
61 ! CHECK-DAG: fir.freemem %[[addr]]
62 end subroutine norm2_test_dim_2
64 ! CHECK-LABEL: func @_QPnorm2_test_dim_3(
65 ! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?x?xf32>>{{.*}}, %[[arg1:.*]]: !fir.box<!fir.array<?x?xf32>>{{.*}})
66 subroutine norm2_test_dim_3(a,r)
67 real :: a(:,:,:)
68 real :: r(:,:)
69 ! CHECK-DAG: %[[dim:.*]] = arith.constant 3 : i32
70 ! CHECK-DAG: %[[r:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x?xf32>>>
71 ! CHECK-DAG: %[[res:.*]] = fir.convert %[[r]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>) -> !fir.ref<!fir.box<none>>
72 ! CHECK: %[[arr:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?x?xf32>>) -> !fir.box<none>
73 r = norm2(a,dim=3)
74 ! CHECK: %{{.*}} = fir.call @_FortranANorm2Dim(%[[res]], %[[arr]], %[[dim]], %{{.*}}, %{{.*}}) {{.*}} : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, !fir.ref<i8>, i32) -> none
75 ! CHECK: %[[box:.*]] = fir.load %[[r]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xf32>>>>
76 ! CHECK-DAG: %[[addr:.*]] = fir.box_addr %[[box]] : (!fir.box<!fir.heap<!fir.array<?x?xf32>>>) -> !fir.heap<!fir.array<?x?xf32>>
77 ! CHECK-DAG: fir.freemem %[[addr]]
78 end subroutine norm2_test_dim_3