Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions libm/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -157,31 +156,36 @@ ifeq ($(TARGET_ARCH),arm)
src/e_ldexpf.c \
src/s_scalbln.c \
src/s_scalbn.c \
src/s_scalbnf.c \
src/e_sqrtf.c

ifeq ($(ARCH_ARM_HAVE_ARMV7A),true)
libm_common_src_files += \
arm/e_pow.S
endif
src/s_scalbnf.c

ifeq ($(TARGET_USE_KRAIT_BIONIC_OPTIMIZATION),true)
libm_common_src_files += \
arm/e_pow.S \
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
ifeq ($(TARGET_USE_SPARROW_BIONIC_OPTIMIZATION),true)
libm_common_src_files += \
arm/e_pow.S
libm_common_cflags += -DSPARROW_NEON_OPTIMIZATION
endif

libm_common_includes = $(LOCAL_PATH)/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)
Expand Down
25 changes: 21 additions & 4 deletions libm/arm/e_pow.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ Copyright (c) 2012, Code Aurora Forum. All rights reserved.
@ Copyright (c) 2012, 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
Expand All @@ -9,7 +9,7 @@
@ 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 Code Aurora Forum, Inc. nor the names of its
@ * 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.
@
Expand All @@ -34,6 +34,7 @@
#define int_1 d29
#define double_1 d28
@ sign and 2^int_n fixup:
#define maxrange r12
#define expadjustment d7
#define literals r10
@ Values which exist within both polynomial implementations:
Expand Down Expand Up @@ -100,13 +101,18 @@
#define vmov_f32 fconsts
#define vmovne_f64 fconstdne

ENTRY(pow_neon)
#define KRAIT_NO_AAPCS_VFP_MODE

ENTRY(pow)
#if defined(KRAIT_NO_AAPCS_VFP_MODE)
@ ARM ABI has inputs coming in via r registers, lets move to a d register
vmov x, x_lw, x_hw
#endif
push {r4, r5, r6, r7, r8, r9, r10, lr}

movw maxrange, #0x0000
movt maxrange, #0x4010

@ pre-staged bp values
vldr bpa, .LbpA
vldr bpb, .LbpB
Expand Down Expand Up @@ -176,6 +182,11 @@ ENTRY(pow_neon)

.Lxle2to3over5:

cmp x_hw, maxrange
cmpls y_hw, maxrange
movt maxrange, #0x3f00
cmpls maxrange, x_hw

@ load log2 polynomial series constants
vldm literals!, {k4, k3, k2, k1}

Expand All @@ -187,6 +198,8 @@ ENTRY(pow_neon)
vsub.f64 u, ss, bp
vadd.f64 v, ss, bp

bhi .LuseFullImpl

@ s = (x-1)/(x+1)
vdiv.f64 ss, u, v

Expand Down Expand Up @@ -393,6 +406,10 @@ ENTRY(pow_neon)
@ leave directly returning whatever is in Return_lw and Return_hw
pop {r4, r5, r6, r7, r8, r9, r10, pc}

.LuseFullImpl:
pop {r4, r5, r6, r7, r8, r9, r10, lr}
b __full_ieee754_pow

.align 6
.LliteralTable:
@ Least-sqares tuned constants for 11th order (log2((1+s)/(1-s)):
Expand Down Expand Up @@ -440,4 +457,4 @@ ENTRY(pow_neon)

.Ltwoto1o4: @ 2^1/4
.long 0x0a31b715, 0x3ff306fe
END(pow_neon)
END(pow)
20 changes: 4 additions & 16 deletions libm/src/e_pow.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_pow.c,v 1.11 2005/02/04 18:2
#include "math.h"
#include "math_private.h"

#if defined(__ARM_NEON__)
#if defined(KRAIT_NO_AAPCS_VFP_MODE)
double pow_neon(double x, double y);
#else
double pow_neon(double x, double y, int32_t lx, int32_t hx) __attribute__((pcs("aapcs-vfp")));
#endif
#endif

static const double
bp[] = {1.0, 1.5,},
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
Expand Down Expand Up @@ -103,7 +95,11 @@ ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/

double
#if defined(KRAIT_NEON_OPTIMIZATION) || defined(SPARROW_NEON_OPTIMIZATION)
__full_ieee754_pow(double x, double y)
#else
__ieee754_pow(double x, double y)
#endif
{
double z,ax,z_h,z_l,p_h,p_l;
double y1,t1,t2,r,s,t,u,v,w;
Expand Down Expand Up @@ -229,14 +225,6 @@ __ieee754_pow(double x, double y)
t1 = u+v;
SET_LOW_WORD(t1,0);
t2 = v-(t1-u);
#if defined(__ARM_NEON__)
} else if (ix <= 0x40100000 && iy <= 0x40100000 && hy > 0 && hx > 0) {
#if defined(KRAIT_NO_AAPCS_VFP_MODE)
return pow_neon(x,y);
#else
return pow_neon(x,y,lx,hx);
#endif
#endif
} else {
double ss,s2,s_h,s_l,t_h,t_l;
n = 0;
Expand Down
1 change: 1 addition & 0 deletions libm/src/math_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ cpackl(long double x, long double y)

/* fdlibm kernel function */
#if defined(KRAIT_NEON_OPTIMIZATION)
double __full_ieee754_pow(double,double);
int __ieee754_rem_pio2(double,double*) __attribute__((pcs("aapcs-vfp")));
double __kernel_sin(double,double,int) __attribute__((pcs("aapcs-vfp")));
double __kernel_cos(double,double) __attribute__((pcs("aapcs-vfp")));
Expand Down