1; Test that combined sin/cos library call is emitted when appropriate
2
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s --check-prefix=CHECK-OPT
4; RUN: llc < %s -mtriple=s390x-linux-gnu -enable-unsafe-fp-math | FileCheck %s --check-prefix=CHECK-OPT
5
6define float @f1(float %x) {
7; CHECK-OPT-LABEL: f1:
8; CHECK-OPT: brasl %r14, sincosf@PLT
9; CHECK-OPT: le %f0, 164(%r15)
10; CHECK-OPT: aeb %f0, 160(%r15)
11  %tmp1 = call float @sinf(float %x) readnone
12  %tmp2 = call float @cosf(float %x) readnone
13  %add = fadd float %tmp1, %tmp2
14  ret float %add
15}
16
17define float @f1_errno(float %x) {
18; CHECK-OPT-LABEL: f1_errno:
19; CHECK-OPT: brasl %r14, sinf@PLT
20; CHECK-OPT: ler %f9, %f0
21; CHECK-OPT: brasl %r14, cosf@PLT
22; CHECK-OPT: aebr %f0, %f9
23  %tmp1 = call float @sinf(float %x)
24  %tmp2 = call float @cosf(float %x)
25  %add = fadd float %tmp1, %tmp2
26  ret float %add
27}
28
29define double @f2(double %x) {
30; CHECK-OPT-LABEL: f2:
31; CHECK-OPT: brasl %r14, sincos@PLT
32; CHECK-OPT: ld %f0, 168(%r15)
33; CHECK-OPT: adb %f0, 160(%r15)
34  %tmp1 = call double @sin(double %x) readnone
35  %tmp2 = call double @cos(double %x) readnone
36  %add = fadd double %tmp1, %tmp2
37  ret double %add
38}
39
40define double @f2_errno(double %x) {
41; CHECK-OPT-LABEL: f2_errno:
42; CHECK-OPT: brasl %r14, sin@PLT
43; CHECK-OPT: ldr %f9, %f0
44; CHECK-OPT: brasl %r14, cos@PLT
45; CHECK-OPT: adbr %f0, %f9
46  %tmp1 = call double @sin(double %x)
47  %tmp2 = call double @cos(double %x)
48  %add = fadd double %tmp1, %tmp2
49  ret double %add
50}
51
52define fp128 @f3(fp128 %x) {
53; CHECK-OPT-LABEL: f3:
54; CHECK-OPT: brasl %r14, sincosl@PLT
55; CHECK-OPT: axbr
56  %tmp1 = call fp128 @sinl(fp128 %x) readnone
57  %tmp2 = call fp128 @cosl(fp128 %x) readnone
58  %add = fadd fp128 %tmp1, %tmp2
59  ret fp128 %add
60}
61
62define fp128 @f3_errno(fp128 %x) {
63; CHECK-OPT-LABEL: f3_errno:
64; CHECK-OPT: brasl %r14, sinl@PLT
65; CHECK-OPT: brasl %r14, cosl@PLT
66; CHECK-OPT: axbr
67  %tmp1 = call fp128 @sinl(fp128 %x)
68  %tmp2 = call fp128 @cosl(fp128 %x)
69  %add = fadd fp128 %tmp1, %tmp2
70  ret fp128 %add
71}
72
73declare float @sinf(float)
74declare double @sin(double)
75declare fp128 @sinl(fp128)
76declare float @cosf(float)
77declare double @cos(double)
78declare fp128 @cosl(fp128)
79
80