[TargetLowering] Android has sincos functions

Since Android API version 9 the Android libm has had the sincos functions, so
they should be recognised as libcalls and sincos optimisation should be applied.

Differential Revision: https://reviews.llvm.org/D52025

llvm-svn: 342471
This commit is contained in:
John Brawn 2018-09-18 13:18:21 +00:00
parent 98d6c5d768
commit 6272ef4ab8
3 changed files with 21 additions and 1 deletions

View File

@ -161,7 +161,8 @@ void TargetLoweringBase::InitLibcalls(const Triple &TT) {
setLibcallName(RTLIB::FPROUND_F32_F16, "__gnu_f2h_ieee");
}
if (TT.isGNUEnvironment() || TT.isOSFuchsia()) {
if (TT.isGNUEnvironment() || TT.isOSFuchsia() ||
(TT.isAndroid() && !TT.isAndroidVersionLT(9))) {
setLibcallName(RTLIB::SINCOS_F32, "sincosf");
setLibcallName(RTLIB::SINCOS_F64, "sincos");
setLibcallName(RTLIB::SINCOS_F80, "sincosl");

View File

@ -1,5 +1,6 @@
; 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
; RUN: llc < %s -mtriple=arm64-linux-android | FileCheck %s --check-prefix CHECK-LINUX
; Combine sin / cos into a single call unless they may write errno (as
; captured by readnone attrbiute, controlled by clang -fmath-errno

View File

@ -3,6 +3,8 @@
; 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
; RUN: llc < %s -mtriple=armv7-linux-android -mcpu=cortex-a8 | FileCheck %s --check-prefix=NOOPT-ANDROID
; RUN: llc < %s -mtriple=armv7-linux-android9 -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS-GNU
; Combine sin / cos into a single call unless they may write errno (as
; captured by readnone attrbiute, controlled by clang -fmath-errno
@ -21,6 +23,10 @@ entry:
; NOOPT: bl _sinf
; NOOPT: bl _cosf
; NOOPT-ANDROID-LABEL: test1:
; NOOPT-ANDROID: bl sinf
; NOOPT-ANDROID: bl cosf
%call = tail call float @sinf(float %x) readnone
%call1 = tail call float @cosf(float %x) readnone
%add = fadd float %call, %call1
@ -41,6 +47,10 @@ entry:
; NOOPT: bl _sinf
; NOOPT: bl _cosf
; NOOPT-ANDROID-LABEL: test1_errno:
; NOOPT-ANDROID: bl sinf
; NOOPT-ANDROID: bl cosf
%call = tail call float @sinf(float %x)
%call1 = tail call float @cosf(float %x)
%add = fadd float %call, %call1
@ -59,6 +69,10 @@ entry:
; NOOPT: bl _sin
; NOOPT: bl _cos
; NOOPT-ANDROID-LABEL: test2:
; NOOPT-ANDROID: bl sin
; NOOPT-ANDROID: bl cos
%call = tail call double @sin(double %x) readnone
%call1 = tail call double @cos(double %x) readnone
%add = fadd double %call, %call1
@ -79,6 +93,10 @@ entry:
; NOOPT: bl _sin
; NOOPT: bl _cos
; NOOPT-ANDROID-LABEL: test2_errno:
; NOOPT-ANDROID: bl sin
; NOOPT-ANDROID: bl cos
%call = tail call double @sin(double %x)
%call1 = tail call double @cos(double %x)
%add = fadd double %call, %call1