1! RUN: bbc -emit-fir %s -o - | FileCheck %s
2
3! Test power operation lowering
4
5! CHECK-LABEL: pow_r4_i4
6subroutine pow_r4_i4(x, y, z)
7  real :: x, z
8  integer :: y
9  z = x ** y
10  ! CHECK: call @llvm.powi.f32.i32
11end subroutine
12
13! CHECK-LABEL: pow_r4_r4
14subroutine pow_r4_r4(x, y, z)
15  real :: x, z, y
16  z = x ** y
17  ! CHECK: math.powf %{{.*}}, %{{.*}} : f32
18end subroutine
19
20! CHECK-LABEL: pow_r4_i8
21subroutine pow_r4_i8(x, y, z)
22  real :: x, z
23  integer(8) :: y
24  z = x ** y
25  ! CHECK: call @__fs_powk_1
26end subroutine
27
28! CHECK-LABEL: pow_r8_i4
29subroutine pow_r8_i4(x, y, z)
30  real(8) :: x, z
31  integer :: y
32  z = x ** y
33  ! CHECK: call @llvm.powi.f64.i32
34end subroutine
35
36! CHECK-LABEL: pow_r8_i8
37subroutine pow_r8_i8(x, y, z)
38  real(8) :: x, z
39  integer(8) :: y
40  z = x ** y
41  ! CHECK: call @__fd_powk_1
42end subroutine
43
44! CHECK-LABEL: pow_r8_r8
45subroutine pow_r8_r8(x, y, z)
46  real(8) :: x, z, y
47  z = x ** y
48  ! CHECK: math.powf %{{.*}}, %{{.*}} : f64
49end subroutine
50
51! CHECK-LABEL: pow_r4_r8
52subroutine pow_r4_r8(x, y, z)
53  real(4) :: x
54  real(8) :: z, y
55  z = x ** y
56  ! CHECK: %{{.*}} = fir.convert %{{.*}} : (f32) -> f64
57  ! CHECK: math.powf %{{.*}}, %{{.*}} : f64
58end subroutine
59
60! CHECK-LABEL: pow_i4_i4
61subroutine pow_i4_i4(x, y, z)
62  integer(4) :: x, y, z
63  z = x ** y
64  ! CHECK: call @__mth_i_ipowi
65end subroutine
66
67! CHECK-LABEL: pow_i8_i8
68subroutine pow_i8_i8(x, y, z)
69  integer(8) :: x, y, z
70  z = x ** y
71  ! CHECK: call @__mth_i_kpowk
72end subroutine
73
74! CHECK-LABEL: pow_c4_i4
75subroutine pow_c4_i4(x, y, z)
76  complex :: x, z
77  integer :: y
78  z = x ** y
79  ! CHECK: call @__fc_powi_1
80end subroutine
81
82! CHECK-LABEL: pow_c4_i8
83subroutine pow_c4_i8(x, y, z)
84  complex :: x, z
85  integer(8) :: y
86  z = x ** y
87  ! CHECK: call @__fc_powk_1
88end subroutine
89
90! CHECK-LABEL: pow_c8_i4
91subroutine pow_c8_i4(x, y, z)
92  complex(8) :: x, z
93  integer :: y
94  z = x ** y
95  ! CHECK: call @__fz_powi_1
96end subroutine
97
98! CHECK-LABEL: pow_c8_i8
99subroutine pow_c8_i8(x, y, z)
100  complex(8) :: x, z
101  integer(8) :: y
102  z = x ** y
103  ! CHECK: call @__fz_powk_1
104end subroutine
105