summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Crowthers <lucasc@codeaurora.org>2013-04-22 16:18:18 -0400
committerSteve Kondik <shade@chemlab.org>2013-05-25 18:48:06 -0700
commit50c1afd4deea0f72dab6ea0b102955a5089edd05 (patch)
tree6fb95d118f485cb4ca142f59bd95422dab0d1aaa
parentefe2f93bbdcdfd64e0bda0544e7f73405585cc1c (diff)
downloadbionic-50c1afd4deea0f72dab6ea0b102955a5089edd05.zip
bionic-50c1afd4deea0f72dab6ea0b102955a5089edd05.tar.gz
bionic-50c1afd4deea0f72dab6ea0b102955a5089edd05.tar.bz2
libm: sqrt and sqrtf via ARM vsqrt instruction.cm-10.1.0-RC3
Optimized sqrt and sqrtf for arm by using hardware opcode for sqrt rather than generic slow portable code. Change-Id: I9888d58547bcfca7dfc1400d3e7e222599167249
-rw-r--r--libm/Android.mk15
-rw-r--r--libm/arm/e_sqrt.S36
-rw-r--r--libm/arm/e_sqrtf.S36
3 files changed, 81 insertions, 6 deletions
diff --git a/libm/Android.mk b/libm/Android.mk
index 1f76366..67c3cb2 100644
--- a/libm/Android.mk
+++ b/libm/Android.mk
@@ -53,7 +53,6 @@ libm_common_src_files:= \
src/e_scalbf.c \
src/e_sinh.c \
src/e_sinhf.c \
- src/e_sqrt.c \
src/k_cos.c \
src/k_cosf.c \
src/k_rem_pio2.c \
@@ -157,8 +156,7 @@ ifeq ($(TARGET_ARCH),arm)
src/e_ldexpf.c \
src/s_scalbln.c \
src/s_scalbn.c \
- src/s_scalbnf.c \
- src/e_sqrtf.c
+ src/s_scalbnf.c
ifeq ($(ARCH_ARM_HAVE_NEON),true)
libm_common_src_files += \
@@ -168,12 +166,16 @@ ifeq ($(TARGET_ARCH),arm)
ifeq ($(TARGET_USE_KRAIT_BIONIC_OPTIMIZATION),true)
libm_common_src_files += \
arm/s_cos.S \
- arm/s_sin.S
+ arm/s_sin.S \
+ arm/e_sqrtf.S \
+ arm/e_sqrt.S
libm_common_cflags += -DKRAIT_NEON_OPTIMIZATION -fno-if-conversion
else
libm_common_src_files += \
src/s_cos.c \
- src/s_sin.c
+ src/s_sin.c \
+ src/e_sqrtf.c \
+ src/e_sqrt.c
endif
libm_common_includes = $(LOCAL_PATH)/arm
@@ -181,7 +183,8 @@ ifeq ($(TARGET_ARCH),arm)
else
libm_common_src_files += \
src/s_cos.c \
- src/s_sin.c
+ src/s_sin.c \
+ src/e_sqrt.c
endif
ifeq ($(TARGET_OS)-$(TARGET_ARCH),linux-x86)
diff --git a/libm/arm/e_sqrt.S b/libm/arm/e_sqrt.S
new file mode 100644
index 0000000..28dc647
--- /dev/null
+++ b/libm/arm/e_sqrt.S
@@ -0,0 +1,36 @@
+@ Copyright (c) 2013, The Linux Foundation. All rights reserved.
+@
+@ Redistribution and use in source and binary forms, with or without
+@ modification, are permitted provided that the following conditions are
+@ met:
+@ * Redistributions of source code must retain the above copyright
+@ notice, this list of conditions and the following disclaimer.
+@ * Redistributions in binary form must reproduce the above
+@ copyright notice, this list of conditions and the following
+@ disclaimer in the documentation and/or other materials provided
+@ with the distribution.
+@ * Neither the name of The Linux Foundation nor the names of its
+@ contributors may be used to endorse or promote products derived
+@ from this software without specific prior written permission.
+@
+@ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+@ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+@ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+@ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+@ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+@ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
+ENTRY(sqrt)
+ vmov.f64 d0, r0, r1
+ vsqrt.f64 d0, d0
+ vmov.f64 r0, r1, d0
+ bx lr
+END(sqrt)
diff --git a/libm/arm/e_sqrtf.S b/libm/arm/e_sqrtf.S
new file mode 100644
index 0000000..4f2e4a0
--- /dev/null
+++ b/libm/arm/e_sqrtf.S
@@ -0,0 +1,36 @@
+@ Copyright (c) 2013, The Linux Foundation. All rights reserved.
+@
+@ Redistribution and use in source and binary forms, with or without
+@ modification, are permitted provided that the following conditions are
+@ met:
+@ * Redistributions of source code must retain the above copyright
+@ notice, this list of conditions and the following disclaimer.
+@ * Redistributions in binary form must reproduce the above
+@ copyright notice, this list of conditions and the following
+@ disclaimer in the documentation and/or other materials provided
+@ with the distribution.
+@ * Neither the name of The Linux Foundation nor the names of its
+@ contributors may be used to endorse or promote products derived
+@ from this software without specific prior written permission.
+@
+@ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+@ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+@ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+@ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+@ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+@ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <machine/cpu-features.h>
+#include <machine/asm.h>
+
+ENTRY(sqrtf)
+ vmov.f32 s0, r0
+ vsqrt.f32 s0, s0
+ vmov.f32 r0, s0
+ bx lr
+END(sqrtf)