1 ; RUN: llc < %s -mtriple=ve | FileCheck %s
3 ;;; Test ‘llvm.sin.*’ intrinsic
6 ;;; This is an overloaded intrinsic. You can use llvm.sin on any
7 ;;; floating-point or vector of floating-point type. Not all targets
8 ;;; support all types however.
10 ;;; declare float @llvm.sin.f32(float %Val)
11 ;;; declare double @llvm.sin.f64(double %Val)
12 ;;; declare x86_fp80 @llvm.sin.f80(x86_fp80 %Val)
13 ;;; declare fp128 @llvm.sin.f128(fp128 %Val)
14 ;;; declare ppc_fp128 @llvm.sin.ppcf128(ppc_fp128 %Val)
17 ;;; The ‘llvm.sin.*’ intrinsics return the sine 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 ‘sin’ 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 @fsin_float_var(float %0) {
34 ; CHECK-LABEL: fsin_float_var:
35 ; CHECK: .LBB{{[0-9]+}}_2:
36 ; CHECK-NEXT: lea %s1, sinf@lo
37 ; CHECK-NEXT: and %s1, %s1, (32)0
38 ; CHECK-NEXT: lea.sl %s12, sinf@hi(, %s1)
39 ; CHECK-NEXT: bsic %s10, (, %s12)
40 ; CHECK-NEXT: or %s11, 0, %s9
41 %2 = tail call fast float @llvm.sin.f32(float %0)
45 ; Function Attrs: nounwind readnone speculatable willreturn
46 declare float @llvm.sin.f32(float)
48 ; Function Attrs: nounwind readnone
49 define double @fsin_double_var(double %0) {
50 ; CHECK-LABEL: fsin_double_var:
51 ; CHECK: .LBB{{[0-9]+}}_2:
52 ; CHECK-NEXT: lea %s1, sin@lo
53 ; CHECK-NEXT: and %s1, %s1, (32)0
54 ; CHECK-NEXT: lea.sl %s12, sin@hi(, %s1)
55 ; CHECK-NEXT: bsic %s10, (, %s12)
56 ; CHECK-NEXT: or %s11, 0, %s9
57 %2 = tail call fast double @llvm.sin.f64(double %0)
61 ; Function Attrs: nounwind readnone speculatable willreturn
62 declare double @llvm.sin.f64(double)
64 ; Function Attrs: nounwind readnone
65 define fp128 @fsin_quad_var(fp128 %0) {
66 ; CHECK-LABEL: fsin_quad_var:
67 ; CHECK: .LBB{{[0-9]+}}_2:
68 ; CHECK-NEXT: lea %s2, sinl@lo
69 ; CHECK-NEXT: and %s2, %s2, (32)0
70 ; CHECK-NEXT: lea.sl %s12, sinl@hi(, %s2)
71 ; CHECK-NEXT: bsic %s10, (, %s12)
72 ; CHECK-NEXT: or %s11, 0, %s9
73 %2 = tail call fast fp128 @llvm.sin.f128(fp128 %0)
77 ; Function Attrs: nounwind readnone speculatable willreturn
78 declare fp128 @llvm.sin.f128(fp128)
80 ; Function Attrs: norecurse nounwind readnone
81 define float @fsin_float_zero() {
82 ; CHECK-LABEL: fsin_float_zero:
84 ; CHECK-NEXT: lea.sl %s0, 0
85 ; CHECK-NEXT: b.l.t (, %s10)
86 ret float 0.000000e+00
89 ; Function Attrs: norecurse nounwind readnone
90 define double @fsin_double_zero() {
91 ; CHECK-LABEL: fsin_double_zero:
93 ; CHECK-NEXT: lea.sl %s0, 0
94 ; CHECK-NEXT: b.l.t (, %s10)
95 ret double 0.000000e+00
98 ; Function Attrs: nounwind readnone
99 define fp128 @fsin_quad_zero() {
100 ; CHECK-LABEL: fsin_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, sinl@lo
108 ; CHECK-NEXT: and %s2, %s2, (32)0
109 ; CHECK-NEXT: lea.sl %s12, sinl@hi(, %s2)
110 ; CHECK-NEXT: bsic %s10, (, %s12)
111 ; CHECK-NEXT: or %s11, 0, %s9
112 %1 = tail call fast fp128 @llvm.sin.f128(fp128 0xL00000000000000000000000000000000)
116 ; Function Attrs: norecurse nounwind readnone
117 define float @fsin_float_const() {
118 ; CHECK-LABEL: fsin_float_const:
120 ; CHECK-NEXT: lea.sl %s0, -1083652169
121 ; CHECK-NEXT: b.l.t (, %s10)
122 ret float 0xBFED18F6E0000000
125 ; Function Attrs: norecurse nounwind readnone
126 define double @fsin_double_const() {
127 ; CHECK-LABEL: fsin_double_const:
129 ; CHECK-NEXT: lea %s0, -355355578
130 ; CHECK-NEXT: and %s0, %s0, (32)0
131 ; CHECK-NEXT: lea.sl %s0, -1074980618(, %s0)
132 ; CHECK-NEXT: b.l.t (, %s10)
133 ret double 0xBFED18F6EAD1B446
136 ; Function Attrs: nounwind readnone
137 define fp128 @fsin_quad_const() {
138 ; CHECK-LABEL: fsin_quad_const:
139 ; CHECK: .LBB{{[0-9]+}}_2:
140 ; CHECK-NEXT: lea %s0, .LCPI{{[0-9]+}}_0@lo
141 ; CHECK-NEXT: and %s0, %s0, (32)0
142 ; CHECK-NEXT: lea.sl %s2, .LCPI{{[0-9]+}}_0@hi(, %s0)
143 ; CHECK-NEXT: ld %s0, 8(, %s2)
144 ; CHECK-NEXT: ld %s1, (, %s2)
145 ; CHECK-NEXT: lea %s2, sinl@lo
146 ; CHECK-NEXT: and %s2, %s2, (32)0
147 ; CHECK-NEXT: lea.sl %s12, sinl@hi(, %s2)
148 ; CHECK-NEXT: bsic %s10, (, %s12)
149 ; CHECK-NEXT: or %s11, 0, %s9
150 %1 = tail call fast fp128 @llvm.sin.f128(fp128 0xL0000000000000000C000000000000000)