xref: /llvm-project/llvm/test/CodeGen/VE/Scalar/pow.ll (revision de8013201f528b7b6ddd8c6500baab8c741f79a1)
1; RUN: llc < %s -mtriple=ve | FileCheck %s
2
3;;; Test ‘llvm.pow.*’ intrinsic
4;;;
5;;; Syntax:
6;;;   This is an overloaded intrinsic. You can use llvm.pow on any
7;;;   floating-point or vector of floating-point type. Not all targets
8;;;   support all types however.
9;;;
10;;; declare float     @llvm.pow.f32(float  %Val, float %Power)
11;;; declare double    @llvm.pow.f64(double %Val, double %Power)
12;;; declare x86_fp80  @llvm.pow.f80(x86_fp80  %Val, x86_fp80 %Power)
13;;; declare fp128     @llvm.pow.f128(fp128 %Val, fp128 %Power)
14;;; declare ppc_fp128 @llvm.pow.ppcf128(ppc_fp128  %Val, ppc_fp128 Power)
15;;;
16;;; Overview:
17;;;   The ‘llvm.pow.*’ intrinsics return the first operand raised to
18;;;   the specified (positive or negative) power.
19;;;
20;;; Arguments:
21;;;   The arguments and return value are floating-point numbers of
22;;;   the same type.
23;;;
24;;; Note:
25;;;   We test only float/double/fp128.
26
27; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
28define float @func_fp_pow_var_float(float noundef %0, float noundef %1) {
29; CHECK-LABEL: func_fp_pow_var_float:
30; CHECK:       .LBB{{[0-9]+}}_2:
31; CHECK-NEXT:    lea %s2, powf@lo
32; CHECK-NEXT:    and %s2, %s2, (32)0
33; CHECK-NEXT:    lea.sl %s12, powf@hi(, %s2)
34; CHECK-NEXT:    bsic %s10, (, %s12)
35; CHECK-NEXT:    or %s11, 0, %s9
36  %3 = tail call fast float @llvm.pow.f32(float %0, float %1)
37  ret float %3
38}
39
40; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn
41declare float @llvm.pow.f32(float, float)
42
43; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
44define double @func_fp_pow_var_double(double noundef %0, double noundef %1) {
45; CHECK-LABEL: func_fp_pow_var_double:
46; CHECK:       .LBB{{[0-9]+}}_2:
47; CHECK-NEXT:    lea %s2, pow@lo
48; CHECK-NEXT:    and %s2, %s2, (32)0
49; CHECK-NEXT:    lea.sl %s12, pow@hi(, %s2)
50; CHECK-NEXT:    bsic %s10, (, %s12)
51; CHECK-NEXT:    or %s11, 0, %s9
52  %3 = tail call fast double @llvm.pow.f64(double %0, double %1)
53  ret double %3
54}
55
56; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn
57declare double @llvm.pow.f64(double, double)
58
59; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
60define fp128 @func_fp_pow_var_quad(fp128 noundef %0, fp128 noundef %1) {
61; CHECK-LABEL: func_fp_pow_var_quad:
62; CHECK:       .LBB{{[0-9]+}}_2:
63; CHECK-NEXT:    lea %s4, powl@lo
64; CHECK-NEXT:    and %s4, %s4, (32)0
65; CHECK-NEXT:    lea.sl %s12, powl@hi(, %s4)
66; CHECK-NEXT:    bsic %s10, (, %s12)
67; CHECK-NEXT:    or %s11, 0, %s9
68  %3 = tail call fast fp128 @llvm.pow.f128(fp128 %0, fp128 %1)
69  ret fp128 %3
70}
71
72; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone speculatable willreturn
73declare fp128 @llvm.pow.f128(fp128, fp128)
74
75; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
76define float @func_fp_pow_zero_back_float(float noundef %0) {
77; CHECK-LABEL: func_fp_pow_zero_back_float:
78; CHECK:       # %bb.0:
79; CHECK-NEXT:    lea.sl %s0, 1065353216
80; CHECK-NEXT:    b.l.t (, %s10)
81  ret float 1.000000e+00
82}
83
84; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
85define double @func_fp_pow_zero_back_double(double noundef %0) {
86; CHECK-LABEL: func_fp_pow_zero_back_double:
87; CHECK:       # %bb.0:
88; CHECK-NEXT:    lea.sl %s0, 1072693248
89; CHECK-NEXT:    b.l.t (, %s10)
90  ret double 1.000000e+00
91}
92
93; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
94define fp128 @func_fp_pow_zero_back_quad(fp128 noundef %0) {
95; CHECK-LABEL: func_fp_pow_zero_back_quad:
96; CHECK:       # %bb.0:
97; CHECK-NEXT:    lea %s0, .LCPI{{[0-9]+}}_0@lo
98; CHECK-NEXT:    and %s0, %s0, (32)0
99; CHECK-NEXT:    lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)
100; CHECK-NEXT:    ld %s0, 8(, %s2)
101; CHECK-NEXT:    ld %s1, (, %s2)
102; CHECK-NEXT:    b.l.t (, %s10)
103  ret fp128 0xL00000000000000003FFF000000000000
104}
105
106; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
107define float @func_fp_pow_zero_fore_float(float noundef %0) {
108; CHECK-LABEL: func_fp_pow_zero_fore_float:
109; CHECK:       .LBB{{[0-9]+}}_2:
110; CHECK-NEXT:    or %s1, 0, %s0
111; CHECK-NEXT:    lea %s0, powf@lo
112; CHECK-NEXT:    and %s0, %s0, (32)0
113; CHECK-NEXT:    lea.sl %s12, powf@hi(, %s0)
114; CHECK-NEXT:    lea.sl %s0, 0
115; CHECK-NEXT:    bsic %s10, (, %s12)
116; CHECK-NEXT:    or %s11, 0, %s9
117  %2 = tail call fast float @llvm.pow.f32(float 0.000000e+00, float %0)
118  ret float %2
119}
120
121; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
122define double @func_fp_pow_zero_fore_double(double noundef %0) {
123; CHECK-LABEL: func_fp_pow_zero_fore_double:
124; CHECK:       .LBB{{[0-9]+}}_2:
125; CHECK-NEXT:    or %s1, 0, %s0
126; CHECK-NEXT:    lea %s0, pow@lo
127; CHECK-NEXT:    and %s0, %s0, (32)0
128; CHECK-NEXT:    lea.sl %s12, pow@hi(, %s0)
129; CHECK-NEXT:    lea.sl %s0, 0
130; CHECK-NEXT:    bsic %s10, (, %s12)
131; CHECK-NEXT:    or %s11, 0, %s9
132  %2 = tail call fast double @llvm.pow.f64(double 0.000000e+00, double %0)
133  ret double %2
134}
135
136; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
137define fp128 @func_fp_pow_zero_fore_quad(fp128 noundef %0) {
138; CHECK-LABEL: func_fp_pow_zero_fore_quad:
139; CHECK:       .LBB{{[0-9]+}}_2:
140; CHECK-NEXT:    or %s2, 0, %s0
141; CHECK-NEXT:    or %s3, 0, %s1
142; CHECK-NEXT:    lea %s0, .LCPI{{[0-9]+}}_0@lo
143; CHECK-NEXT:    and %s0, %s0, (32)0
144; CHECK-NEXT:    lea.sl %s4, .LCPI{{[0-9]+}}_0@hi(, %s0)
145; CHECK-NEXT:    ld %s0, 8(, %s4)
146; CHECK-NEXT:    ld %s1, (, %s4)
147; CHECK-NEXT:    lea %s4, powl@lo
148; CHECK-NEXT:    and %s4, %s4, (32)0
149; CHECK-NEXT:    lea.sl %s12, powl@hi(, %s4)
150; CHECK-NEXT:    bsic %s10, (, %s12)
151; CHECK-NEXT:    or %s11, 0, %s9
152  %2 = tail call fast fp128 @llvm.pow.f128(fp128 0xL00000000000000000000000000000000, fp128 %0)
153  ret fp128 %2
154}
155
156; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
157define float @func_fp_pow_const_back_float(float noundef %0) {
158; CHECK-LABEL: func_fp_pow_const_back_float:
159; CHECK:       # %bb.0:
160; CHECK-NEXT:    fmul.s %s0, %s0, %s0
161; CHECK-NEXT:    lea.sl %s1, 1065353216
162; CHECK-NEXT:    fdiv.s %s0, %s1, %s0
163; CHECK-NEXT:    b.l.t (, %s10)
164  %2 = tail call fast float @llvm.powi.f32.i32(float %0, i32 -2)
165  ret float %2
166}
167
168; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
169define double @func_fp_pow_const_back_double(double noundef %0) {
170; CHECK-LABEL: func_fp_pow_const_back_double:
171; CHECK:       # %bb.0:
172; CHECK-NEXT:    fmul.d %s0, %s0, %s0
173; CHECK-NEXT:    lea.sl %s1, 1072693248
174; CHECK-NEXT:    fdiv.d %s0, %s1, %s0
175; CHECK-NEXT:    b.l.t (, %s10)
176  %2 = tail call fast double @llvm.powi.f64.i32(double %0, i32 -2)
177  ret double %2
178}
179
180; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
181define fp128 @func_fp_pow_const_back_quad(fp128 noundef %0) {
182; CHECK-LABEL: func_fp_pow_const_back_quad:
183; CHECK:       .LBB{{[0-9]+}}_2:
184; CHECK-NEXT:    fmul.q %s2, %s0, %s0
185; CHECK-NEXT:    lea %s0, .LCPI{{[0-9]+}}_0@lo
186; CHECK-NEXT:    and %s0, %s0, (32)0
187; CHECK-NEXT:    lea.sl %s4, .LCPI{{[0-9]+}}_0@hi(, %s0)
188; CHECK-NEXT:    ld %s0, 8(, %s4)
189; CHECK-NEXT:    ld %s1, (, %s4)
190; CHECK-NEXT:    lea %s4, __divtf3@lo
191; CHECK-NEXT:    and %s4, %s4, (32)0
192; CHECK-NEXT:    lea.sl %s12, __divtf3@hi(, %s4)
193; CHECK-NEXT:    bsic %s10, (, %s12)
194; CHECK-NEXT:    or %s11, 0, %s9
195  %2 = tail call fast fp128 @llvm.powi.f128.i32(fp128 %0, i32 -2)
196  ret fp128 %2
197}
198
199; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
200define float @func_fp_pow_const_fore_float(float noundef %0) {
201; CHECK-LABEL: func_fp_pow_const_fore_float:
202; CHECK:       .LBB{{[0-9]+}}_2:
203; CHECK-NEXT:    or %s1, 0, %s0
204; CHECK-NEXT:    lea %s0, powf@lo
205; CHECK-NEXT:    and %s0, %s0, (32)0
206; CHECK-NEXT:    lea.sl %s12, powf@hi(, %s0)
207; CHECK-NEXT:    lea.sl %s0, -1073741824
208; CHECK-NEXT:    bsic %s10, (, %s12)
209; CHECK-NEXT:    or %s11, 0, %s9
210  %2 = tail call fast float @llvm.pow.f32(float -2.000000e+00, float %0)
211  ret float %2
212}
213
214; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
215define double @func_fp_pow_const_fore_double(double noundef %0) {
216; CHECK-LABEL: func_fp_pow_const_fore_double:
217; CHECK:       .LBB{{[0-9]+}}_2:
218; CHECK-NEXT:    or %s1, 0, %s0
219; CHECK-NEXT:    lea %s0, pow@lo
220; CHECK-NEXT:    and %s0, %s0, (32)0
221; CHECK-NEXT:    lea.sl %s12, pow@hi(, %s0)
222; CHECK-NEXT:    lea.sl %s0, -1073741824
223; CHECK-NEXT:    bsic %s10, (, %s12)
224; CHECK-NEXT:    or %s11, 0, %s9
225  %2 = tail call fast double @llvm.pow.f64(double -2.000000e+00, double %0)
226  ret double %2
227}
228
229; Function Attrs: mustprogress nofree nosync nounwind readnone willreturn
230define fp128 @func_fp_pow_const_fore_quad(fp128 noundef %0) {
231; CHECK-LABEL: func_fp_pow_const_fore_quad:
232; CHECK:       .LBB{{[0-9]+}}_2:
233; CHECK-NEXT:    or %s2, 0, %s0
234; CHECK-NEXT:    or %s3, 0, %s1
235; CHECK-NEXT:    lea %s0, .LCPI{{[0-9]+}}_0@lo
236; CHECK-NEXT:    and %s0, %s0, (32)0
237; CHECK-NEXT:    lea.sl %s4, .LCPI{{[0-9]+}}_0@hi(, %s0)
238; CHECK-NEXT:    ld %s0, 8(, %s4)
239; CHECK-NEXT:    ld %s1, (, %s4)
240; CHECK-NEXT:    lea %s4, powl@lo
241; CHECK-NEXT:    and %s4, %s4, (32)0
242; CHECK-NEXT:    lea.sl %s12, powl@hi(, %s4)
243; CHECK-NEXT:    bsic %s10, (, %s12)
244; CHECK-NEXT:    or %s11, 0, %s9
245  %2 = tail call fast fp128 @llvm.pow.f128(fp128 0xL0000000000000000C000000000000000, fp128 %0)
246  ret fp128 %2
247}
248
249; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
250declare float @llvm.powi.f32.i32(float, i32)
251
252; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
253declare double @llvm.powi.f64.i32(double, i32)
254
255; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
256declare fp128 @llvm.powi.f128.i32(fp128, i32)
257