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-NOOPT
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
12; CHECK-NOOPT-LABEL: f1:
13; CHECK-NOOPT: brasl %r14, sinf@PLT
14; CHECK-NOOPT: brasl %r14, cosf@PLT
15  %tmp1 = call float @sinf(float %x)
16  %tmp2 = call float @cosf(float %x)
17  %add = fadd float %tmp1, %tmp2
18  ret float %add
19}
20
21define double @f2(double %x) {
22; CHECK-OPT-LABEL: f2:
23; CHECK-OPT: brasl %r14, sincos@PLT
24; CHECK-OPT: ld %f0, 168(%r15)
25; CHECK-OPT: adb %f0, 160(%r15)
26
27; CHECK-NOOPT-LABEL: f2:
28; CHECK-NOOPT: brasl %r14, sin@PLT
29; CHECK-NOOPT: brasl %r14, cos@PLT
30  %tmp1 = call double @sin(double %x)
31  %tmp2 = call double @cos(double %x)
32  %add = fadd double %tmp1, %tmp2
33  ret double %add
34}
35
36define fp128 @f3(fp128 %x) {
37; CHECK-OPT-LABEL: f3:
38; CHECK-OPT: brasl %r14, sincosl@PLT
39; CHECK-OPT: axbr
40
41; CHECK-NOOPT-LABEL: f3:
42; CHECK-NOOPT: brasl %r14, sinl@PLT
43; CHECK-NOOPT: brasl %r14, cosl@PLT
44  %tmp1 = call fp128 @sinl(fp128 %x)
45  %tmp2 = call fp128 @cosl(fp128 %x)
46  %add = fadd fp128 %tmp1, %tmp2
47  ret fp128 %add
48}
49
50declare float @sinf(float) readonly
51declare double @sin(double) readonly
52declare fp128 @sinl(fp128) readonly
53declare float @cosf(float) readonly
54declare double @cos(double) readonly
55declare fp128 @cosl(fp128) readonly
56
57