[llvm] r305204 - [SelectionDAG] Allow sin/cos -> sincos optimization on GNU triples w/ just -fno-math-errno
Geoff Berry via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 12 10:15:41 PDT 2017
Author: gberry
Date: Mon Jun 12 12:15:41 2017
New Revision: 305204
URL: http://llvm.org/viewvc/llvm-project?rev=305204&view=rev
Log:
[SelectionDAG] Allow sin/cos -> sincos optimization on GNU triples w/ just -fno-math-errno
Summary:
This change enables the sin(x) cos(x) -> sincos(x) optimization on GNU
target triples. This optimization was being inhibited when -ffast-math
wasn't set because sincos in GLibC does not set errno, while sin and cos
do. However, this optimization will only run if the attributes on the
sin/cos calls include readnone, which is how clang represents the fact
that it doesn't care about the errno values set by these functions (via
the -fno-math-errno flag).
Reviewers: hfinkel, bogner
Subscribers: mcrosier, javed.absar, llvm-commits, paul.redmond
Differential Revision: https://reviews.llvm.org/D32921
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/trunk/test/CodeGen/AArch64/arm64-sincos.ll
llvm/trunk/test/CodeGen/AArch64/sincos-expansion.ll
llvm/trunk/test/CodeGen/ARM/sincos.ll
llvm/trunk/test/CodeGen/SystemZ/fp-sincos-01.ll
llvm/trunk/test/CodeGen/X86/sincos-opt.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=305204&r1=305203&r2=305204&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Jun 12 12:15:41 2017
@@ -2192,19 +2192,6 @@ static bool isSinCosLibcallAvailable(SDN
return TLI.getLibcallName(LC) != nullptr;
}
-/// Return true if sincos libcall is available and can be used to combine sin
-/// and cos.
-static bool canCombineSinCosLibcall(SDNode *Node, const TargetLowering &TLI,
- const TargetMachine &TM) {
- if (!isSinCosLibcallAvailable(Node, TLI))
- return false;
- // GNU sin/cos functions set errno while sincos does not. Therefore
- // combining sin and cos is only safe if unsafe-fpmath is enabled.
- if (TM.getTargetTriple().isGNUEnvironment() && !TM.Options.UnsafeFPMath)
- return false;
- return true;
-}
-
/// Only issue sincos libcall if both sin and cos are needed.
static bool useSinCos(SDNode *Node) {
unsigned OtherOpcode = Node->getOpcode() == ISD::FSIN
@@ -3247,7 +3234,7 @@ bool SelectionDAGLegalize::ExpandNode(SD
// Turn fsin / fcos into ISD::FSINCOS node if there are a pair of fsin /
// fcos which share the same operand and both are used.
if ((TLI.isOperationLegalOrCustom(ISD::FSINCOS, VT) ||
- canCombineSinCosLibcall(Node, TLI, TM))
+ isSinCosLibcallAvailable(Node, TLI))
&& useSinCos(Node)) {
SDVTList VTs = DAG.getVTList(VT, VT);
Tmp1 = DAG.getNode(ISD::FSINCOS, dl, VTs, Node->getOperand(0));
Modified: llvm/trunk/test/CodeGen/AArch64/arm64-sincos.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/arm64-sincos.ll?rev=305204&r1=305203&r2=305204&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/arm64-sincos.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/arm64-sincos.ll Mon Jun 12 12:15:41 2017
@@ -1,7 +1,9 @@
; RUN: llc < %s -mtriple=arm64-apple-ios7 | FileCheck %s --check-prefix CHECK-IOS
; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s --check-prefix CHECK-LINUX
-; Combine sin / cos into a single call.
+; Combine sin / cos into a single call unless they may write errno (as
+; captured by readnone attrbiute, controlled by clang -fmath-errno
+; setting).
; rdar://12856873
define float @test1(float %x) nounwind {
@@ -11,11 +13,26 @@ entry:
; CHECK-IOS: fadd s0, s0, s1
; CHECK-LINUX-LABEL: test1:
+; CHECK-LINUX: bl sincosf
+
+ %call = tail call float @sinf(float %x) readnone
+ %call1 = tail call float @cosf(float %x) readnone
+ %add = fadd float %call, %call1
+ ret float %add
+}
+
+define float @test1_errno(float %x) nounwind {
+entry:
+; CHECK-IOS-LABEL: test1_errno:
+; CHECK-IOS: bl _sinf
+; CHECK-IOS: bl _cosf
+
+; CHECK-LINUX-LABEL: test1_errno:
; CHECK-LINUX: bl sinf
; CHECK-LINUX: bl cosf
- %call = tail call float @sinf(float %x) nounwind readnone
- %call1 = tail call float @cosf(float %x) nounwind readnone
+ %call = tail call float @sinf(float %x)
+ %call1 = tail call float @cosf(float %x)
%add = fadd float %call, %call1
ret float %add
}
@@ -27,16 +44,31 @@ entry:
; CHECK-IOS: fadd d0, d0, d1
; CHECK-LINUX-LABEL: test2:
+; CHECK-LINUX: bl sincos
+
+ %call = tail call double @sin(double %x) readnone
+ %call1 = tail call double @cos(double %x) readnone
+ %add = fadd double %call, %call1
+ ret double %add
+}
+
+define double @test2_errno(double %x) nounwind {
+entry:
+; CHECK-IOS-LABEL: test2_errno:
+; CHECK-IOS: bl _sin
+; CHECK-IOS: bl _cos
+
+; CHECK-LINUX-LABEL: test2_errno:
; CHECK-LINUX: bl sin
; CHECK-LINUX: bl cos
- %call = tail call double @sin(double %x) nounwind readnone
- %call1 = tail call double @cos(double %x) nounwind readnone
+ %call = tail call double @sin(double %x)
+ %call1 = tail call double @cos(double %x)
%add = fadd double %call, %call1
ret double %add
}
-declare float @sinf(float) readonly
-declare double @sin(double) readonly
-declare float @cosf(float) readonly
-declare double @cos(double) readonly
+declare float @sinf(float)
+declare double @sin(double)
+declare float @cosf(float)
+declare double @cos(double)
Modified: llvm/trunk/test/CodeGen/AArch64/sincos-expansion.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/sincos-expansion.ll?rev=305204&r1=305203&r2=305204&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/sincos-expansion.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/sincos-expansion.ll Mon Jun 12 12:15:41 2017
@@ -1,8 +1,18 @@
; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s
define float @test_sincos_f32(float %f) {
+; CHECK-LABEL: test_sincos_f32:
%sin = call float @sinf(float %f) readnone
%cos = call float @cosf(float %f) readnone
+; CHECK: bl sincosf
+ %val = fadd float %sin, %cos
+ ret float %val
+}
+
+define float @test_sincos_f32_errno(float %f) {
+; CHECK-LABEL: test_sincos_f32_errno:
+ %sin = call float @sinf(float %f)
+ %cos = call float @cosf(float %f)
; CHECK: bl sinf
; CHECK: bl cosf
%val = fadd float %sin, %cos
@@ -10,26 +20,46 @@ define float @test_sincos_f32(float %f)
}
define double @test_sincos_f64(double %f) {
+; CHECK-LABEL: test_sincos_f64:
%sin = call double @sin(double %f) readnone
%cos = call double @cos(double %f) readnone
%val = fadd double %sin, %cos
+; CHECK: bl sincos
+ ret double %val
+}
+
+define double @test_sincos_f64_errno(double %f) {
+; CHECK-LABEL: test_sincos_f64_errno:
+ %sin = call double @sin(double %f)
+ %cos = call double @cos(double %f)
+ %val = fadd double %sin, %cos
; CHECK: bl sin
; CHECK: bl cos
ret double %val
}
define fp128 @test_sincos_f128(fp128 %f) {
+; CHECK-LABEL: test_sincos_f128:
%sin = call fp128 @sinl(fp128 %f) readnone
%cos = call fp128 @cosl(fp128 %f) readnone
%val = fadd fp128 %sin, %cos
+; CHECK: bl sincosl
+ ret fp128 %val
+}
+
+define fp128 @test_sincos_f128_errno(fp128 %f) {
+; CHECK-LABEL: test_sincos_f128_errno:
+ %sin = call fp128 @sinl(fp128 %f)
+ %cos = call fp128 @cosl(fp128 %f)
+ %val = fadd fp128 %sin, %cos
; CHECK: bl sinl
; CHECK: bl cosl
ret fp128 %val
}
-declare float @sinf(float) readonly
-declare double @sin(double) readonly
-declare fp128 @sinl(fp128) readonly
-declare float @cosf(float) readonly
-declare double @cos(double) readonly
-declare fp128 @cosl(fp128) readonly
+declare float @sinf(float)
+declare double @sin(double)
+declare fp128 @sinl(fp128)
+declare float @cosf(float)
+declare double @cos(double)
+declare fp128 @cosl(fp128)
Modified: llvm/trunk/test/CodeGen/ARM/sincos.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/sincos.ll?rev=305204&r1=305203&r2=305204&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/sincos.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/sincos.ll Mon Jun 12 12:15:41 2017
@@ -1,10 +1,12 @@
; RUN: llc < %s -mtriple=armv7-apple-ios6 -mcpu=cortex-a8 | FileCheck %s --check-prefix=NOOPT
; RUN: llc < %s -mtriple=armv7-apple-ios7 -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS
-; RUN: llc < %s -mtriple=armv7-linux-gnu -mcpu=cortex-a8 | FileCheck %s --check-prefix=NOOPT-GNU
+; RUN: llc < %s -mtriple=armv7-linux-gnu -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS-GNU
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a8 \
; RUN: --enable-unsafe-fp-math | FileCheck %s --check-prefix=SINCOS-GNU
-; Combine sin / cos into a single call.
+; Combine sin / cos into a single call unless they may write errno (as
+; captured by readnone attrbiute, controlled by clang -fmath-errno
+; setting).
; rdar://12856873
define float @test1(float %x) nounwind {
@@ -19,12 +21,28 @@ entry:
; NOOPT: bl _sinf
; NOOPT: bl _cosf
-; NOOPT-GNU-LABEL: test1:
-; NOOPT-GNU: bl sinf
-; NOOPT-GNU: bl cosf
+ %call = tail call float @sinf(float %x) readnone
+ %call1 = tail call float @cosf(float %x) readnone
+ %add = fadd float %call, %call1
+ ret float %add
+}
+
+define float @test1_errno(float %x) nounwind {
+entry:
+; SINCOS-LABEL: test1_errno:
+; SINCOS: bl _sinf
+; SINCOS: bl _cosf
+
+; SINCOS-GNU-LABEL: test1_errno:
+; SINCOS-GNU: bl sinf
+; SINCOS-GNU: bl cosf
- %call = tail call float @sinf(float %x) nounwind readnone
- %call1 = tail call float @cosf(float %x) nounwind readnone
+; NOOPT-LABEL: test1_errno:
+; NOOPT: bl _sinf
+; NOOPT: bl _cosf
+
+ %call = tail call float @sinf(float %x)
+ %call1 = tail call float @cosf(float %x)
%add = fadd float %call, %call1
ret float %add
}
@@ -41,16 +59,33 @@ entry:
; NOOPT: bl _sin
; NOOPT: bl _cos
-; NOOPT-GNU-LABEL: test2:
-; NOOPT-GNU: bl sin
-; NOOPT-GNU: bl cos
- %call = tail call double @sin(double %x) nounwind readnone
- %call1 = tail call double @cos(double %x) nounwind readnone
+ %call = tail call double @sin(double %x) readnone
+ %call1 = tail call double @cos(double %x) readnone
+ %add = fadd double %call, %call1
+ ret double %add
+}
+
+define double @test2_errno(double %x) nounwind {
+entry:
+; SINCOS-LABEL: test2_errno:
+; SINCOS: bl _sin
+; SINCOS: bl _cos
+
+; SINCOS-GNU-LABEL: test2_errno:
+; SINCOS-GNU: bl sin
+; SINCOS-GNU: bl cos
+
+; NOOPT-LABEL: test2_errno:
+; NOOPT: bl _sin
+; NOOPT: bl _cos
+
+ %call = tail call double @sin(double %x)
+ %call1 = tail call double @cos(double %x)
%add = fadd double %call, %call1
ret double %add
}
-declare float @sinf(float) readonly
-declare double @sin(double) readonly
-declare float @cosf(float) readonly
-declare double @cos(double) readonly
+declare float @sinf(float)
+declare double @sin(double)
+declare float @cosf(float)
+declare double @cos(double)
Modified: llvm/trunk/test/CodeGen/SystemZ/fp-sincos-01.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/fp-sincos-01.ll?rev=305204&r1=305203&r2=305204&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/SystemZ/fp-sincos-01.ll (original)
+++ llvm/trunk/test/CodeGen/SystemZ/fp-sincos-01.ll Mon Jun 12 12:15:41 2017
@@ -1,6 +1,6 @@
; Test that combined sin/cos library call is emitted when appropriate
-; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s --check-prefix=CHECK-NOOPT
+; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s --check-prefix=CHECK-OPT
; RUN: llc < %s -mtriple=s390x-linux-gnu -enable-unsafe-fp-math | FileCheck %s --check-prefix=CHECK-OPT
define float @f1(float %x) {
@@ -8,10 +8,18 @@ define float @f1(float %x) {
; CHECK-OPT: brasl %r14, sincosf at PLT
; CHECK-OPT: le %f0, 164(%r15)
; CHECK-OPT: aeb %f0, 160(%r15)
+ %tmp1 = call float @sinf(float %x) readnone
+ %tmp2 = call float @cosf(float %x) readnone
+ %add = fadd float %tmp1, %tmp2
+ ret float %add
+}
-; CHECK-NOOPT-LABEL: f1:
-; CHECK-NOOPT: brasl %r14, sinf at PLT
-; CHECK-NOOPT: brasl %r14, cosf at PLT
+define float @f1_errno(float %x) {
+; CHECK-OPT-LABEL: f1_errno:
+; CHECK-OPT: brasl %r14, sinf at PLT
+; CHECK-OPT: ler %f9, %f0
+; CHECK-OPT: brasl %r14, cosf at PLT
+; CHECK-OPT: aebr %f0, %f9
%tmp1 = call float @sinf(float %x)
%tmp2 = call float @cosf(float %x)
%add = fadd float %tmp1, %tmp2
@@ -23,10 +31,18 @@ define double @f2(double %x) {
; CHECK-OPT: brasl %r14, sincos at PLT
; CHECK-OPT: ld %f0, 168(%r15)
; CHECK-OPT: adb %f0, 160(%r15)
+ %tmp1 = call double @sin(double %x) readnone
+ %tmp2 = call double @cos(double %x) readnone
+ %add = fadd double %tmp1, %tmp2
+ ret double %add
+}
-; CHECK-NOOPT-LABEL: f2:
-; CHECK-NOOPT: brasl %r14, sin at PLT
-; CHECK-NOOPT: brasl %r14, cos at PLT
+define double @f2_errno(double %x) {
+; CHECK-OPT-LABEL: f2_errno:
+; CHECK-OPT: brasl %r14, sin at PLT
+; CHECK-OPT: ldr %f9, %f0
+; CHECK-OPT: brasl %r14, cos at PLT
+; CHECK-OPT: adbr %f0, %f9
%tmp1 = call double @sin(double %x)
%tmp2 = call double @cos(double %x)
%add = fadd double %tmp1, %tmp2
@@ -37,20 +53,27 @@ define fp128 @f3(fp128 %x) {
; CHECK-OPT-LABEL: f3:
; CHECK-OPT: brasl %r14, sincosl at PLT
; CHECK-OPT: axbr
+ %tmp1 = call fp128 @sinl(fp128 %x) readnone
+ %tmp2 = call fp128 @cosl(fp128 %x) readnone
+ %add = fadd fp128 %tmp1, %tmp2
+ ret fp128 %add
+}
-; CHECK-NOOPT-LABEL: f3:
-; CHECK-NOOPT: brasl %r14, sinl at PLT
-; CHECK-NOOPT: brasl %r14, cosl at PLT
+define fp128 @f3_errno(fp128 %x) {
+; CHECK-OPT-LABEL: f3_errno:
+; CHECK-OPT: brasl %r14, sinl at PLT
+; CHECK-OPT: brasl %r14, cosl at PLT
+; CHECK-OPT: axbr
%tmp1 = call fp128 @sinl(fp128 %x)
%tmp2 = call fp128 @cosl(fp128 %x)
%add = fadd fp128 %tmp1, %tmp2
ret fp128 %add
}
-declare float @sinf(float) readonly
-declare double @sin(double) readonly
-declare fp128 @sinl(fp128) readonly
-declare float @cosf(float) readonly
-declare double @cos(double) readonly
-declare fp128 @cosl(fp128) readonly
+declare float @sinf(float)
+declare double @sin(double)
+declare fp128 @sinl(fp128)
+declare float @cosf(float)
+declare double @cos(double)
+declare fp128 @cosl(fp128)
Modified: llvm/trunk/test/CodeGen/X86/sincos-opt.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sincos-opt.ll?rev=305204&r1=305203&r2=305204&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sincos-opt.ll (original)
+++ llvm/trunk/test/CodeGen/X86/sincos-opt.ll Mon Jun 12 12:15:41 2017
@@ -1,10 +1,12 @@
; RUN: llc < %s -mtriple=x86_64-apple-macosx10.9.0 -mcpu=core2 | FileCheck %s --check-prefix=OSX_SINCOS
; RUN: llc < %s -mtriple=x86_64-apple-macosx10.8.0 -mcpu=core2 | FileCheck %s --check-prefix=OSX_NOOPT
-; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 | FileCheck %s --check-prefix=GNU_NOOPT
-; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS
-; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNUX32_SINCOS
-
-; Combine sin / cos into a single call.
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 | FileCheck %s --check-prefix=GNU_SINCOS
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnux32 -mcpu=core2 -enable-unsafe-fp-math | FileCheck %s --check-prefix=GNU_SINCOS_FASTMATH
+
+; Combine sin / cos into a single call unless they may write errno (as
+; captured by readnone attrbiute, controlled by clang -fmath-errno
+; setting).
; rdar://13087969
; rdar://13599493
@@ -15,25 +17,44 @@ entry:
; GNU_SINCOS: movss 4(%rsp), %xmm0
; GNU_SINCOS: addss (%rsp), %xmm0
-; GNUX32_SINCOS-LABEL: test1:
-; GNUX32_SINCOS: callq sincosf
-; GNUX32_SINCOS: movss 4(%esp), %xmm0
-; GNUX32_SINCOS: addss (%esp), %xmm0
-
-; GNU_NOOPT: test1
-; GNU_NOOPT: callq sinf
-; GNU_NOOPT: callq cosf
+; GNU_SINCOS_FASTMATH-LABEL: test1:
+; GNU_SINCOS_FASTMATH: callq sincosf
+; GNU_SINCOS_FASTMATH: movss 4(%{{[re]}}sp), %xmm0
+; GNU_SINCOS_FASTMATH: addss (%{{[re]}}sp), %xmm0
; OSX_SINCOS-LABEL: test1:
; OSX_SINCOS: callq ___sincosf_stret
; OSX_SINCOS: movshdup {{.*}} xmm1 = xmm0[1,1,3,3]
; OSX_SINCOS: addss %xmm1, %xmm0
-; OSX_NOOPT: test1
+; OSX_NOOPT-LABEL: test1:
+; OSX_NOOPT: callq _sinf
+; OSX_NOOPT: callq _cosf
+ %call = tail call float @sinf(float %x) readnone
+ %call1 = tail call float @cosf(float %x) readnone
+ %add = fadd float %call, %call1
+ ret float %add
+}
+
+define float @test1_errno(float %x) nounwind {
+entry:
+; GNU_SINCOS-LABEL: test1_errno:
+; GNU_SINCOS: callq sinf
+; GNU_SINCOS: callq cosf
+
+; GNU_SINCOS_FASTMATH-LABEL: test1_errno:
+; GNU_SINCOS_FASTMATH: callq sinf
+; GNU_SINCOS_FASTMATH: callq cosf
+
+; OSX_SINCOS-LABEL: test1_errno:
+; OSX_SINCOS: callq _sinf
+; OSX_SINCOS: callq _cosf
+
+; OSX_NOOPT-LABEL: test1_errno:
; OSX_NOOPT: callq _sinf
; OSX_NOOPT: callq _cosf
- %call = tail call float @sinf(float %x) nounwind readnone
- %call1 = tail call float @cosf(float %x) nounwind readnone
+ %call = tail call float @sinf(float %x)
+ %call1 = tail call float @cosf(float %x)
%add = fadd float %call, %call1
ret float %add
}
@@ -45,24 +66,43 @@ entry:
; GNU_SINCOS: movsd 16(%rsp), %xmm0
; GNU_SINCOS: addsd 8(%rsp), %xmm0
-; GNUX32_SINCOS-LABEL: test2:
-; GNUX32_SINCOS: callq sincos
-; GNUX32_SINCOS: movsd 16(%esp), %xmm0
-; GNUX32_SINCOS: addsd 8(%esp), %xmm0
-
-; GNU_NOOPT: test2:
-; GNU_NOOPT: callq sin
-; GNU_NOOPT: callq cos
+; GNU_SINCOS_FASTMATH-LABEL: test2:
+; GNU_SINCOS_FASTMATH: callq sincos
+; GNU_SINCOS_FASTMATH: movsd 16(%{{[re]}}sp), %xmm0
+; GNU_SINCOS_FASTMATH: addsd 8(%{{[re]}}sp), %xmm0
; OSX_SINCOS-LABEL: test2:
; OSX_SINCOS: callq ___sincos_stret
; OSX_SINCOS: addsd %xmm1, %xmm0
-; OSX_NOOPT: test2
+; OSX_NOOPT-LABEL: test2:
+; OSX_NOOPT: callq _sin
+; OSX_NOOPT: callq _cos
+ %call = tail call double @sin(double %x) readnone
+ %call1 = tail call double @cos(double %x) readnone
+ %add = fadd double %call, %call1
+ ret double %add
+}
+
+define double @test2_errno(double %x) nounwind {
+entry:
+; GNU_SINCOS-LABEL: test2_errno:
+; GNU_SINCOS: callq sin
+; GNU_SINCOS: callq cos
+
+; GNU_SINCOS_FASTMATH-LABEL: test2_errno:
+; GNU_SINCOS_FASTMATH: callq sin
+; GNU_SINCOS_FASTMATH: callq cos
+
+; OSX_SINCOS-LABEL: test2_errno:
+; OSX_SINCOS: callq _sin
+; OSX_SINCOS: callq _cos
+
+; OSX_NOOPT-LABEL: test2_errno:
; OSX_NOOPT: callq _sin
; OSX_NOOPT: callq _cos
- %call = tail call double @sin(double %x) nounwind readnone
- %call1 = tail call double @cos(double %x) nounwind readnone
+ %call = tail call double @sin(double %x)
+ %call1 = tail call double @cos(double %x)
%add = fadd double %call, %call1
ret double %add
}
@@ -70,29 +110,40 @@ entry:
define x86_fp80 @test3(x86_fp80 %x) nounwind {
entry:
; GNU_SINCOS-LABEL: test3:
+; GNU_SINCOS: callq sincosl
+; GNU_SINCOS: fldt 16(%rsp)
+; GNU_SINCOS: fldt 32(%rsp)
+; GNU_SINCOS: faddp %st(1)
+
+; GNU_SINCOS_FASTMATH-LABEL: test3:
+; GNU_SINCOS_FASTMATH: fsin
+; GNU_SINCOS_FASTMATH: fcos
+; GNU_SINCOS_FASTMATH: faddp %st(1)
+; GNU_SINCOS_FASTMATH: ret
+ %call = tail call x86_fp80 @sinl(x86_fp80 %x) readnone
+ %call1 = tail call x86_fp80 @cosl(x86_fp80 %x) readnone
+ %add = fadd x86_fp80 %call, %call1
+ ret x86_fp80 %add
+}
+
+define x86_fp80 @test3_errno(x86_fp80 %x) nounwind {
+entry:
+; GNU_SINCOS-LABEL: test3_errno:
; GNU_SINCOS: callq sinl
; GNU_SINCOS: callq cosl
-; GNU_SINCOS: ret
-
-; GNUX32_SINCOS-LABEL: test3:
-; GNUX32_SINCOS: callq sinl
-; GNUX32_SINCOS: callq cosl
-; GNUX32_SINCOS: ret
-
-; GNU_NOOPT: test3:
-; GNU_NOOPT: callq sinl
-; GNU_NOOPT: callq cosl
- %call = tail call x86_fp80 @sinl(x86_fp80 %x) nounwind
- %call1 = tail call x86_fp80 @cosl(x86_fp80 %x) nounwind
+; GNU_SINCOS_FASTMATH-LABEL: test3_errno:
+; GNU_SINCOS_FASTMATH: callq sinl
+; GNU_SINCOS_FASTMATH: callq cosl
+ %call = tail call x86_fp80 @sinl(x86_fp80 %x)
+ %call1 = tail call x86_fp80 @cosl(x86_fp80 %x)
%add = fadd x86_fp80 %call, %call1
ret x86_fp80 %add
}
-declare float @sinf(float) readonly
-declare double @sin(double) readonly
-declare float @cosf(float) readonly
-declare double @cos(double) readonly
-
+declare float @sinf(float)
+declare double @sin(double)
+declare float @cosf(float)
+declare double @cos(double)
declare x86_fp80 @sinl(x86_fp80)
declare x86_fp80 @cosl(x86_fp80)
More information about the llvm-commits
mailing list