summaryrefslogtreecommitdiff
path: root/test/CodeGen/SystemZ
diff options
context:
space:
mode:
authorGeoff Berry <gberry@codeaurora.org>2017-06-12 17:15:41 +0000
committerGeoff Berry <gberry@codeaurora.org>2017-06-12 17:15:41 +0000
commit57098b0fe9650718714b53930dc7b4d824f7bd87 (patch)
tree10d533ca327e5d4d307c897f0638cc8edaa64cff /test/CodeGen/SystemZ
parent24acabd9f9c529e6ead59b7460fd8fe59d664eab (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305204 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/SystemZ')
-rw-r--r--test/CodeGen/SystemZ/fp-sincos-01.ll55
1 files changed, 39 insertions, 16 deletions
diff --git a/test/CodeGen/SystemZ/fp-sincos-01.ll b/test/CodeGen/SystemZ/fp-sincos-01.ll
index cd182a590ee..4a38d7afba2 100644
--- a/test/CodeGen/SystemZ/fp-sincos-01.ll
+++ b/test/CodeGen/SystemZ/fp-sincos-01.ll
@@ -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@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@PLT
-; CHECK-NOOPT: brasl %r14, cosf@PLT
+define float @f1_errno(float %x) {
+; CHECK-OPT-LABEL: f1_errno:
+; CHECK-OPT: brasl %r14, sinf@PLT
+; CHECK-OPT: ler %f9, %f0
+; CHECK-OPT: brasl %r14, cosf@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@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@PLT
-; CHECK-NOOPT: brasl %r14, cos@PLT
+define double @f2_errno(double %x) {
+; CHECK-OPT-LABEL: f2_errno:
+; CHECK-OPT: brasl %r14, sin@PLT
+; CHECK-OPT: ldr %f9, %f0
+; CHECK-OPT: brasl %r14, cos@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@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@PLT
-; CHECK-NOOPT: brasl %r14, cosl@PLT
+define fp128 @f3_errno(fp128 %x) {
+; CHECK-OPT-LABEL: f3_errno:
+; CHECK-OPT: brasl %r14, sinl@PLT
+; CHECK-OPT: brasl %r14, cosl@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)