1 ; RUN: llc < %s -mtriple=ve | FileCheck %s
3 ;;; Test ‘llvm.cos.*’ intrinsic
6 ;;; This is an overloaded intrinsic. You can use llvm.cos on any
7 ;;; floating-point or vector of floating-point type. Not all targets
8 ;;; support all types however.
10 ;;; declare float @llvm.cos.f32(float %Val)
11 ;;; declare double @llvm.cos.f64(double %Val)
12 ;;; declare x86_fp80 @llvm.cos.f80(x86_fp80 %Val)
13 ;;; declare fp128 @llvm.cos.f128(fp128 %Val)
14 ;;; declare ppc_fp128 @llvm.cos.ppcf128(ppc_fp128 %Val)
17 ;;; The ‘llvm.cos.*’ intrinsics return the cosine of the operand.
20 ;;; The argument and return value are floating-point numbers of the same type.
23 ;;; Return the same value as a corresponding libm ‘cos’ function but without
24 ;;; trapping or setting errno.
26 ;;; When specified with the fast-math-flag ‘afn’, the result may be
27 ;;; approximated using a less accurate calculation.
30 ;;; We test only float/double/fp128.
32 ; Function Attrs: nounwind readnone
33 define float @fcos_float_var(float %0) {
34 ; CHECK-LABEL: fcos_float_var:
35 ; CHECK: .LBB{{[0-9]+}}_2:
36 ; CHECK-NEXT: lea %s1, cosf@lo
37 ; CHECK-NEXT: and %s1, %s1, (32)0
38 ; CHECK-NEXT: lea.sl %s12, cosf@hi(, %s1)
39 ; CHECK-NEXT: bsic %s10, (, %s12)
40 ; CHECK-NEXT: or %s11, 0, %s9
41 %2 = tail call fast float @llvm.cos.f32(float %0)
45 ; Function Attrs: nounwind readnone speculatable willreturn
46 declare float @llvm.cos.f32(float)
48 ; Function Attrs: nounwind readnone
49 define double @fcos_double_var(double %0) {
50 ; CHECK-LABEL: fcos_double_var:
51 ; CHECK: .LBB{{[0-9]+}}_2:
52 ; CHECK-NEXT: lea %s1, cos@lo
53 ; CHECK-NEXT: and %s1, %s1, (32)0
54 ; CHECK-NEXT: lea.sl %s12, cos@hi(, %s1)
55 ; CHECK-NEXT: bsic %s10, (, %s12)
56 ; CHECK-NEXT: or %s11, 0, %s9
57 %2 = tail call fast double @llvm.cos.f64(double %0)
61 ; Function Attrs: nounwind readnone speculatable willreturn
62 declare double @llvm.cos.f64(double)
64 ; Function Attrs: nounwind readnone
65 define fp128 @fcos_quad_var(fp128 %0) {
66 ; CHECK-LABEL: fcos_quad_var:
67 ; CHECK: .LBB{{[0-9]+}}_2:
68 ; CHECK-NEXT: lea %s2, cosl@lo
69 ; CHECK-NEXT: and %s2, %s2, (32)0
70 ; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2)
71 ; CHECK-NEXT: bsic %s10, (, %s12)
72 ; CHECK-NEXT: or %s11, 0, %s9
73 %2 = tail call fast fp128 @llvm.cos.f128(fp128 %0)
77 ; Function Attrs: nounwind readnone speculatable willreturn
78 declare fp128 @llvm.cos.f128(fp128)
80 ; Function Attrs: norecurse nounwind readnone
81 define float @fcos_float_zero() {
82 ; CHECK-LABEL: fcos_float_zero:
84 ; CHECK-NEXT: lea.sl %s0, 1065353216
85 ; CHECK-NEXT: b.l.t (, %s10)
86 ret float 1.000000e+00
89 ; Function Attrs: norecurse nounwind readnone
90 define double @fcos_double_zero() {
91 ; CHECK-LABEL: fcos_double_zero:
93 ; CHECK-NEXT: lea.sl %s0, 1072693248
94 ; CHECK-NEXT: b.l.t (, %s10)
95 ret double 1.000000e+00
98 ; Function Attrs: nounwind readnone
99 define fp128 @fcos_quad_zero() {
100 ; CHECK-LABEL: fcos_quad_zero:
101 ; CHECK: .LBB{{[0-9]+}}_2:
102 ; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo
103 ; CHECK-NEXT: and %s0, %s0, (32)0
104 ; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)
105 ; CHECK-NEXT: ld %s0, 8(, %s2)
106 ; CHECK-NEXT: ld %s1, (, %s2)
107 ; CHECK-NEXT: lea %s2, cosl@lo
108 ; CHECK-NEXT: and %s2, %s2, (32)0
109 ; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2)
110 ; CHECK-NEXT: bsic %s10, (, %s12)
111 ; CHECK-NEXT: or %s11, 0, %s9
112 %1 = tail call fast fp128 @llvm.cos.f128(fp128 0xL00000000000000000000000000000000)
116 ; Function Attrs: norecurse nounwind readnone
117 define float @fcos_float_const() {
118 ; CHECK-LABEL: fcos_float_const:
120 ; CHECK-NEXT: lea.sl %s0, -1093332685
121 ; CHECK-NEXT: b.l.t (, %s10)
122 ret float 0xBFDAA22660000000
125 ; Function Attrs: norecurse nounwind readnone
126 define double @fcos_double_const() {
127 ; CHECK-LABEL: fcos_double_const:
129 ; CHECK-NEXT: lea %s0, 1465086469
130 ; CHECK-NEXT: lea.sl %s0, -1076190682(, %s0)
131 ; CHECK-NEXT: b.l.t (, %s10)
132 ret double 0xBFDAA22657537205
135 ; Function Attrs: nounwind readnone
136 define fp128 @fcos_quad_const() {
137 ; CHECK-LABEL: fcos_quad_const:
138 ; CHECK: .LBB{{[0-9]+}}_2:
139 ; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo
140 ; CHECK-NEXT: and %s0, %s0, (32)0
141 ; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)
142 ; CHECK-NEXT: ld %s0, 8(, %s2)
143 ; CHECK-NEXT: ld %s1, (, %s2)
144 ; CHECK-NEXT: lea %s2, cosl@lo
145 ; CHECK-NEXT: and %s2, %s2, (32)0
146 ; CHECK-NEXT: lea.sl %s12, cosl@hi(, %s2)
147 ; CHECK-NEXT: bsic %s10, (, %s12)
148 ; CHECK-NEXT: or %s11, 0, %s9
149 %1 = tail call fast fp128 @llvm.cos.f128(fp128 0xL0000000000000000C000000000000000)