From 35d8ba303b3b21f25ce66d8602ed36672145de3f Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 21 Aug 2018 19:02:42 -0300 Subject: [PATCH] arm64: Use builtin for nearbyintf/nearbyint This allows compiler optimize both calls to a single frinti. Test: Builds, ran unit tests on arm64. Change-Id: Ie59ac11a419281836a8051ecda26a5c7b72f3dea --- libm/Android.bp | 2 ++ libm/builtins.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/libm/Android.bp b/libm/Android.bp index 3b88fa3a8..c0862c807 100644 --- a/libm/Android.bp +++ b/libm/Android.bp @@ -315,6 +315,8 @@ cc_library { "upstream-freebsd/lib/msun/src/s_llrintf.c", "upstream-freebsd/lib/msun/src/s_lrint.c", "upstream-freebsd/lib/msun/src/s_lrintf.c", + "upstream-freebsd/lib/msun/src/s_nearbyintf.c", + "upstream-freebsd/lib/msun/src/s_nearbyint.c", "upstream-freebsd/lib/msun/src/s_rint.c", "upstream-freebsd/lib/msun/src/s_rintf.c", "upstream-freebsd/lib/msun/src/s_round.c", diff --git a/libm/builtins.cpp b/libm/builtins.cpp index 2ea63055c..515b68a80 100644 --- a/libm/builtins.cpp +++ b/libm/builtins.cpp @@ -57,4 +57,12 @@ double fmin(double x, double y) { return __builtin_fmin(x, y); } float roundf(float x) { return __builtin_roundf(x); } double round(double x) { return __builtin_round(x); } + +float nearbyintf(float x) { return __builtin_nearbyintf(x); } +double nearbyint(double x) { return __builtin_nearbyint(x); } +// msun s_nearbyint.c defines all floating-point version, so we need to +// redefine the long double one here. For aarch64, clang/compiler-rt +// soft-float routines does not use single/double floating-point operation, +// so it should be safe to call rintl directly. +long double nearbyintl(long double x) { return rintl(x); } #endif