[PATCH] D52025: [TargetLowering] Android has sincos functions

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 13 04:27:19 PDT 2018


john.brawn created this revision.
john.brawn added reviewers: pcc, srhines, pirama.
Herald added a reviewer: javed.absar.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D52025

Files:
  lib/CodeGen/TargetLoweringBase.cpp
  test/CodeGen/AArch64/arm64-sincos.ll
  test/CodeGen/ARM/sincos.ll


Index: test/CodeGen/ARM/sincos.ll
===================================================================
--- test/CodeGen/ARM/sincos.ll
+++ test/CodeGen/ARM/sincos.ll
@@ -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 @@
 ; 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 @@
 ; 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 @@
 ; 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 @@
 ; 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
Index: test/CodeGen/AArch64/arm64-sincos.ll
===================================================================
--- test/CodeGen/AArch64/arm64-sincos.ll
+++ test/CodeGen/AArch64/arm64-sincos.ll
@@ -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
Index: lib/CodeGen/TargetLoweringBase.cpp
===================================================================
--- lib/CodeGen/TargetLoweringBase.cpp
+++ lib/CodeGen/TargetLoweringBase.cpp
@@ -161,7 +161,8 @@
     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");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52025.165246.patch
Type: text/x-patch
Size: 3077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180913/8a2e79ce/attachment.bin>


More information about the llvm-commits mailing list