|
|
147e83 |
commit 656b84c2ef525e3b69802c9057c5897e327b0332
|
|
|
147e83 |
Author: Wilco Dijkstra <wdijkstr@arm.com>
|
|
|
147e83 |
Date: Thu Aug 7 16:29:55 2014 +0000
|
|
|
147e83 |
|
|
|
147e83 |
This patch adds new function libc_feholdsetround_noex_aarch64_ctx, enabling
|
|
|
147e83 |
further optimization. libc_feholdsetround_aarch64_ctx now only needs to
|
|
|
147e83 |
read the FPCR in the typical case, avoiding a redundant FPSR read.
|
|
|
147e83 |
Performance results show a good improvement (5-10% on sin()) on cores with
|
|
|
147e83 |
expensive FPCR/FPSR instructions.
|
|
|
147e83 |
|
|
|
147e83 |
diff --git a/ports/sysdeps/aarch64/fpu/math_private.h b/ports/sysdeps/aarch64/fpu/math_private.h
|
|
|
147e83 |
index 023c9d0..b13c030 100644
|
|
|
147e83 |
--- a/ports/sysdeps/aarch64/fpu/math_private.h
|
|
|
147e83 |
+++ b/ports/sysdeps/aarch64/fpu/math_private.h
|
|
|
147e83 |
@@ -228,12 +228,9 @@ static __always_inline void
|
|
|
147e83 |
libc_feholdsetround_aarch64_ctx (struct rm_ctx *ctx, int r)
|
|
|
147e83 |
{
|
|
|
147e83 |
fpu_control_t fpcr;
|
|
|
147e83 |
- fpu_fpsr_t fpsr;
|
|
|
147e83 |
int round;
|
|
|
147e83 |
|
|
|
147e83 |
_FPU_GETCW (fpcr);
|
|
|
147e83 |
- _FPU_GETFPSR (fpsr);
|
|
|
147e83 |
- ctx->env.__fpsr = fpsr;
|
|
|
147e83 |
|
|
|
147e83 |
/* Check whether rounding modes are different. */
|
|
|
147e83 |
round = (fpcr ^ r) & _FPU_FPCR_RM_MASK;
|
|
|
147e83 |
@@ -264,6 +261,33 @@ libc_feresetround_aarch64_ctx (struct rm_ctx *ctx)
|
|
|
147e83 |
#define libc_feresetroundl_ctx libc_feresetround_aarch64_ctx
|
|
|
147e83 |
|
|
|
147e83 |
static __always_inline void
|
|
|
147e83 |
+libc_feholdsetround_noex_aarch64_ctx (struct rm_ctx *ctx, int r)
|
|
|
147e83 |
+{
|
|
|
147e83 |
+ fpu_control_t fpcr;
|
|
|
147e83 |
+ fpu_fpsr_t fpsr;
|
|
|
147e83 |
+ int round;
|
|
|
147e83 |
+
|
|
|
147e83 |
+ _FPU_GETCW (fpcr);
|
|
|
147e83 |
+ _FPU_GETFPSR (fpsr);
|
|
|
147e83 |
+ ctx->env.__fpsr = fpsr;
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Check whether rounding modes are different. */
|
|
|
147e83 |
+ round = (fpcr ^ r) & _FPU_FPCR_RM_MASK;
|
|
|
147e83 |
+ ctx->updated_status = round != 0;
|
|
|
147e83 |
+
|
|
|
147e83 |
+ /* Set the rounding mode if changed. */
|
|
|
147e83 |
+ if (__glibc_unlikely (round != 0))
|
|
|
147e83 |
+ {
|
|
|
147e83 |
+ ctx->env.__fpcr = fpcr;
|
|
|
147e83 |
+ _FPU_SETCW (fpcr ^ round);
|
|
|
147e83 |
+ }
|
|
|
147e83 |
+}
|
|
|
147e83 |
+
|
|
|
147e83 |
+#define libc_feholdsetround_noex_ctx libc_feholdsetround_noex_aarch64_ctx
|
|
|
147e83 |
+#define libc_feholdsetround_noexf_ctx libc_feholdsetround_noex_aarch64_ctx
|
|
|
147e83 |
+#define libc_feholdsetround_noexl_ctx libc_feholdsetround_noex_aarch64_ctx
|
|
|
147e83 |
+
|
|
|
147e83 |
+static __always_inline void
|
|
|
147e83 |
libc_feresetround_noex_aarch64_ctx (struct rm_ctx *ctx)
|
|
|
147e83 |
{
|
|
|
147e83 |
/* Restore the rounding mode if updated. */
|