• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=x86_64-apple-macosx10.9.0 -mcpu=core2 | FileCheck %s --check-prefix=OSX_SINCOS
2; RUN: llc < %s -mtriple=x86_64-apple-macosx10.8.0 -mcpu=core2 | FileCheck %s --check-prefix=OSX_NOOPT
3; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS
4; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH
5; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH
6; RUN: llc < %s -mtriple=x86_64-fuchsia -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS
7; RUN: llc < %s -mtriple=x86_64-fuchsia -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH
8
9; Combine sin / cos into a single call unless they may write errno (as
10; captured by readnone attrbiute, controlled by clang -fmath-errno
11; setting).
12; rdar://13087969
13; rdar://13599493
14
15define float @test1(float %x) nounwind {
16entry:
17; GNU_SINCOS-LABEL: test1:
18; GNU_SINCOS: callq sincosf
19; GNU_SINCOS: movss 4(%rsp), %xmm0
20; GNU_SINCOS: addss (%rsp), %xmm0
21
22; GNU_SINCOS_FASTMATH-LABEL: test1:
23; GNU_SINCOS_FASTMATH: callq sincosf
24; GNU_SINCOS_FASTMATH: movss 4(%{{[re]}}sp), %xmm0
25; GNU_SINCOS_FASTMATH: addss (%{{[re]}}sp), %xmm0
26
27; OSX_SINCOS-LABEL: test1:
28; OSX_SINCOS: callq ___sincosf_stret
29; OSX_SINCOS: movshdup {{.*}} xmm1 = xmm0[1,1,3,3]
30; OSX_SINCOS: addss %xmm1, %xmm0
31
32; OSX_NOOPT-LABEL: test1:
33; OSX_NOOPT: callq _sinf
34; OSX_NOOPT: callq _cosf
35  %call = tail call float @sinf(float %x) readnone
36  %call1 = tail call float @cosf(float %x) readnone
37  %add = fadd float %call, %call1
38  ret float %add
39}
40
41define float @test1_errno(float %x) nounwind {
42entry:
43; GNU_SINCOS-LABEL: test1_errno:
44; GNU_SINCOS: callq sinf
45; GNU_SINCOS: callq cosf
46
47; GNU_SINCOS_FASTMATH-LABEL: test1_errno:
48; GNU_SINCOS_FASTMATH: callq sinf
49; GNU_SINCOS_FASTMATH: callq cosf
50
51; OSX_SINCOS-LABEL: test1_errno:
52; OSX_SINCOS: callq _sinf
53; OSX_SINCOS: callq _cosf
54
55; OSX_NOOPT-LABEL: test1_errno:
56; OSX_NOOPT: callq _sinf
57; OSX_NOOPT: callq _cosf
58  %call = tail call float @sinf(float %x)
59  %call1 = tail call float @cosf(float %x)
60  %add = fadd float %call, %call1
61  ret float %add
62}
63
64define double @test2(double %x) nounwind {
65entry:
66; GNU_SINCOS-LABEL: test2:
67; GNU_SINCOS: callq sincos
68; GNU_SINCOS: movsd 16(%rsp), %xmm0
69; GNU_SINCOS: addsd 8(%rsp), %xmm0
70
71; GNU_SINCOS_FASTMATH-LABEL: test2:
72; GNU_SINCOS_FASTMATH: callq sincos
73; GNU_SINCOS_FASTMATH: movsd 16(%{{[re]}}sp), %xmm0
74; GNU_SINCOS_FASTMATH: addsd 8(%{{[re]}}sp), %xmm0
75
76; OSX_SINCOS-LABEL: test2:
77; OSX_SINCOS: callq ___sincos_stret
78; OSX_SINCOS: addsd %xmm1, %xmm0
79
80; OSX_NOOPT-LABEL: test2:
81; OSX_NOOPT: callq _sin
82; OSX_NOOPT: callq _cos
83  %call = tail call double @sin(double %x) readnone
84  %call1 = tail call double @cos(double %x) readnone
85  %add = fadd double %call, %call1
86  ret double %add
87}
88
89define double @test2_errno(double %x) nounwind {
90entry:
91; GNU_SINCOS-LABEL: test2_errno:
92; GNU_SINCOS: callq sin
93; GNU_SINCOS: callq cos
94
95; GNU_SINCOS_FASTMATH-LABEL: test2_errno:
96; GNU_SINCOS_FASTMATH: callq sin
97; GNU_SINCOS_FASTMATH: callq cos
98
99; OSX_SINCOS-LABEL: test2_errno:
100; OSX_SINCOS: callq _sin
101; OSX_SINCOS: callq _cos
102
103; OSX_NOOPT-LABEL: test2_errno:
104; OSX_NOOPT: callq _sin
105; OSX_NOOPT: callq _cos
106  %call = tail call double @sin(double %x)
107  %call1 = tail call double @cos(double %x)
108  %add = fadd double %call, %call1
109  ret double %add
110}
111
112define x86_fp80 @test3(x86_fp80 %x) nounwind {
113entry:
114; GNU_SINCOS-LABEL: test3:
115; GNU_SINCOS: callq sincosl
116; GNU_SINCOS: fldt 16(%rsp)
117; GNU_SINCOS: fldt 32(%rsp)
118; GNU_SINCOS: faddp %st(1)
119
120; GNU_SINCOS_FASTMATH-LABEL: test3:
121; GNU_SINCOS_FASTMATH: callq sincosl
122; GNU_SINCOS_FASTMATH: fldt 16(%{{[re]}}sp)
123; GNU_SINCOS_FASTMATH: fldt 32(%{{[re]}}sp)
124; GNU_SINCOS_FASTMATH: faddp %st(1)
125  %call = tail call x86_fp80 @sinl(x86_fp80 %x) readnone
126  %call1 = tail call x86_fp80 @cosl(x86_fp80 %x) readnone
127  %add = fadd x86_fp80 %call, %call1
128  ret x86_fp80 %add
129}
130
131define x86_fp80 @test3_errno(x86_fp80 %x) nounwind {
132entry:
133; GNU_SINCOS-LABEL: test3_errno:
134; GNU_SINCOS: callq sinl
135; GNU_SINCOS: callq cosl
136
137; GNU_SINCOS_FASTMATH-LABEL: test3_errno:
138; GNU_SINCOS_FASTMATH: callq sinl
139; GNU_SINCOS_FASTMATH: callq cosl
140  %call = tail call x86_fp80 @sinl(x86_fp80 %x)
141  %call1 = tail call x86_fp80 @cosl(x86_fp80 %x)
142  %add = fadd x86_fp80 %call, %call1
143  ret x86_fp80 %add
144}
145
146declare float  @sinf(float)
147declare double @sin(double)
148declare float @cosf(float)
149declare double @cos(double)
150declare x86_fp80 @sinl(x86_fp80)
151declare x86_fp80 @cosl(x86_fp80)
152