[flang] Add cpowi function to runtime and use instead of pgmath
[platform/upstream/llvm.git] / flang / test / Lower / power-operator.f90
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2
3 ! Test power operation lowering
4
5 ! CHECK-LABEL: pow_r4_i4
6 subroutine pow_r4_i4(x, y, z)
7   real :: x, z
8   integer :: y
9   z = x ** y
10   ! CHECK: call @llvm.powi.f32.i32
11 end subroutine
12
13 ! CHECK-LABEL: pow_r4_r4
14 subroutine pow_r4_r4(x, y, z)
15   real :: x, z, y
16   z = x ** y
17   ! CHECK: math.powf %{{.*}}, %{{.*}} : f32
18 end subroutine
19
20 ! CHECK-LABEL: pow_r4_i8
21 subroutine pow_r4_i8(x, y, z)
22   real :: x, z
23   integer(8) :: y
24   z = x ** y
25   ! CHECK: call @__fs_powk_1
26 end subroutine
27
28 ! CHECK-LABEL: pow_r8_i4
29 subroutine 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
34 end subroutine
35
36 ! CHECK-LABEL: pow_r8_i8
37 subroutine 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
42 end subroutine
43
44 ! CHECK-LABEL: pow_r8_r8
45 subroutine pow_r8_r8(x, y, z)
46   real(8) :: x, z, y
47   z = x ** y
48   ! CHECK: math.powf %{{.*}}, %{{.*}} : f64
49 end subroutine
50
51 ! CHECK-LABEL: pow_r4_r8
52 subroutine 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
58 end subroutine
59
60 ! CHECK-LABEL: pow_i1_i1
61 subroutine pow_i1_i1(x, y, z)
62   integer(1) :: x, y, z
63   z = x ** y
64   ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i8
65 end subroutine
66
67 ! CHECK-LABEL: pow_i2_i2
68 subroutine pow_i2_i2(x, y, z)
69   integer(2) :: x, y, z
70   z = x ** y
71   ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i16
72 end subroutine
73
74 ! CHECK-LABEL: pow_i4_i4
75 subroutine pow_i4_i4(x, y, z)
76   integer(4) :: x, y, z
77   z = x ** y
78   ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i32
79 end subroutine
80
81 ! CHECK-LABEL: pow_i8_i8
82 subroutine pow_i8_i8(x, y, z)
83   integer(8) :: x, y, z
84   z = x ** y
85   ! CHECK: math.ipowi %{{.*}}, %{{.*}} : i64
86 end subroutine
87
88 ! CHECK-LABEL: pow_c4_i4
89 subroutine pow_c4_i4(x, y, z)
90   complex :: x, z
91   integer :: y
92   z = x ** y
93   ! CHECK: call @_FortranAcpowi
94 end subroutine
95
96 ! CHECK-LABEL: pow_c4_i8
97 subroutine pow_c4_i8(x, y, z)
98   complex :: x, z
99   integer(8) :: y
100   z = x ** y
101   ! CHECK: call @_FortranAcpowk
102 end subroutine
103
104 ! CHECK-LABEL: pow_c8_i4
105 subroutine pow_c8_i4(x, y, z)
106   complex(8) :: x, z
107   integer :: y
108   z = x ** y
109   ! CHECK: call @_FortranAzpowi
110 end subroutine
111
112 ! CHECK-LABEL: pow_c8_i8
113 subroutine pow_c8_i8(x, y, z)
114   complex(8) :: x, z
115   integer(8) :: y
116   z = x ** y
117   ! CHECK: call @_FortranAzpowk
118 end subroutine
119
120 ! CHECK-LABEL: pow_c4_c4
121 subroutine pow_c4_c4(x, y, z)
122   complex :: x, y, z
123   z = x ** y
124   ! CHECK: call @cpowf
125 end subroutine
126
127 ! CHECK-LABEL: pow_c8_c8
128 subroutine pow_c8_c8(x, y, z)
129   complex(8) :: x, y, z
130   z = x ** y
131   ! CHECK: call @cpow
132 end subroutine
133