• 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_NOOPT
4; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS
5; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNUX32_SINCOS
6
7; Combine sin / cos into a single call.
8; rdar://13087969
9; rdar://13599493
10
11define float @test1(float %x) nounwind {
12entry:
13; GNU_SINCOS-LABEL: test1:
14; GNU_SINCOS: callq sincosf
15; GNU_SINCOS: movss 4(%rsp), %xmm0
16; GNU_SINCOS: addss (%rsp), %xmm0
17
18; GNUX32_SINCOS-LABEL: test1:
19; GNUX32_SINCOS: callq sincosf
20; GNUX32_SINCOS: movss 4(%esp), %xmm0
21; GNUX32_SINCOS: addss (%esp), %xmm0
22
23; GNU_NOOPT: test1
24; GNU_NOOPT: callq sinf
25; GNU_NOOPT: callq cosf
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: test1
33; OSX_NOOPT: callq _sinf
34; OSX_NOOPT: callq _cosf
35  %call = tail call float @sinf(float %x) nounwind readnone
36  %call1 = tail call float @cosf(float %x) nounwind readnone
37  %add = fadd float %call, %call1
38  ret float %add
39}
40
41define double @test2(double %x) nounwind {
42entry:
43; GNU_SINCOS-LABEL: test2:
44; GNU_SINCOS: callq sincos
45; GNU_SINCOS: movsd 16(%rsp), %xmm0
46; GNU_SINCOS: addsd 8(%rsp), %xmm0
47
48; GNUX32_SINCOS-LABEL: test2:
49; GNUX32_SINCOS: callq sincos
50; GNUX32_SINCOS: movsd 16(%esp), %xmm0
51; GNUX32_SINCOS: addsd 8(%esp), %xmm0
52
53; GNU_NOOPT: test2:
54; GNU_NOOPT: callq sin
55; GNU_NOOPT: callq cos
56
57; OSX_SINCOS-LABEL: test2:
58; OSX_SINCOS: callq ___sincos_stret
59; OSX_SINCOS: addsd %xmm1, %xmm0
60
61; OSX_NOOPT: test2
62; OSX_NOOPT: callq _sin
63; OSX_NOOPT: callq _cos
64  %call = tail call double @sin(double %x) nounwind readnone
65  %call1 = tail call double @cos(double %x) nounwind readnone
66  %add = fadd double %call, %call1
67  ret double %add
68}
69
70define x86_fp80 @test3(x86_fp80 %x) nounwind {
71entry:
72; GNU_SINCOS-LABEL: test3:
73; GNU_SINCOS: callq sinl
74; GNU_SINCOS: callq cosl
75; GNU_SINCOS: ret
76
77; GNUX32_SINCOS-LABEL: test3:
78; GNUX32_SINCOS: callq sinl
79; GNUX32_SINCOS: callq cosl
80; GNUX32_SINCOS: ret
81
82; GNU_NOOPT: test3:
83; GNU_NOOPT: callq sinl
84; GNU_NOOPT: callq cosl
85
86  %call = tail call x86_fp80 @sinl(x86_fp80 %x) nounwind
87  %call1 = tail call x86_fp80 @cosl(x86_fp80 %x) nounwind
88  %add = fadd x86_fp80 %call, %call1
89  ret x86_fp80 %add
90}
91
92declare float  @sinf(float) readonly
93declare double @sin(double) readonly
94declare float @cosf(float) readonly
95declare double @cos(double) readonly
96
97declare x86_fp80 @sinl(x86_fp80)
98declare x86_fp80 @cosl(x86_fp80)
99