about summary refs log tree commit diff
path: root/sysdeps/aarch64/fpu/log_advsimd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/aarch64/fpu/log_advsimd.c')
-rw-r--r--sysdeps/aarch64/fpu/log_advsimd.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/sysdeps/aarch64/fpu/log_advsimd.c b/sysdeps/aarch64/fpu/log_advsimd.c
index 434737f2a9..8b32d1cfe1 100644
--- a/sysdeps/aarch64/fpu/log_advsimd.c
+++ b/sysdeps/aarch64/fpu/log_advsimd.c
@@ -21,9 +21,11 @@
 
 static const struct data
 {
+  uint64x2_t min_norm;
+  uint32x4_t special_bound;
   float64x2_t poly[5];
   float64x2_t ln2;
-  uint64x2_t min_norm, special_bound, sign_exp_mask;
+  uint64x2_t sign_exp_mask;
 } data = {
   /* Worst-case error: 1.17 + 0.5 ulp.
      Rel error: 0x1.6272e588p-56 in [ -0x1.fc1p-9 0x1.009p-8 ].  */
@@ -32,7 +34,7 @@ static const struct data
 	    V2 (-0x1.554e550bd501ep-3) },
   .ln2 = V2 (0x1.62e42fefa39efp-1),
   .min_norm = V2 (0x0010000000000000),
-  .special_bound = V2 (0x7fe0000000000000), /* asuint64(inf) - min_norm.  */
+  .special_bound = V4 (0x7fe00000), /* asuint64(inf) - min_norm.  */
   .sign_exp_mask = V2 (0xfff0000000000000)
 };
 
@@ -52,29 +54,34 @@ lookup (uint64x2_t i)
 {
   /* Since N is a power of 2, n % N = n & (N - 1).  */
   struct entry e;
-  e.invc[0] = __v_log_data.invc[i[0] & IndexMask];
-  e.logc[0] = __v_log_data.logc[i[0] & IndexMask];
-  e.invc[1] = __v_log_data.invc[i[1] & IndexMask];
-  e.logc[1] = __v_log_data.logc[i[1] & IndexMask];
+  uint64_t i0 = (i[0] >> (52 - V_LOG_TABLE_BITS)) & IndexMask;
+  uint64_t i1 = (i[1] >> (52 - V_LOG_TABLE_BITS)) & IndexMask;
+  float64x2_t e0 = vld1q_f64 (&__v_log_data.table[i0].invc);
+  float64x2_t e1 = vld1q_f64 (&__v_log_data.table[i1].invc);
+  e.invc = vuzp1q_f64 (e0, e1);
+  e.logc = vuzp2q_f64 (e0, e1);
   return e;
 }
 
 static float64x2_t VPCS_ATTR NOINLINE
-special_case (float64x2_t x, float64x2_t y, uint64x2_t cmp)
+special_case (float64x2_t x, float64x2_t y, float64x2_t hi, float64x2_t r2,
+	      uint32x2_t cmp)
 {
-  return v_call_f64 (log, x, y, cmp);
+  return v_call_f64 (log, x, vfmaq_f64 (hi, y, r2), vmovl_u32 (cmp));
 }
 
 float64x2_t VPCS_ATTR V_NAME_D1 (log) (float64x2_t x)
 {
   const struct data *d = ptr_barrier (&data);
   float64x2_t z, r, r2, p, y, kd, hi;
-  uint64x2_t ix, iz, tmp, cmp;
+  uint64x2_t ix, iz, tmp;
+  uint32x2_t cmp;
   int64x2_t k;
   struct entry e;
 
   ix = vreinterpretq_u64_f64 (x);
-  cmp = vcgeq_u64 (vsubq_u64 (ix, d->min_norm), d->special_bound);
+  cmp = vcge_u32 (vsubhn_u64 (ix, d->min_norm),
+		  vget_low_u32 (d->special_bound));
 
   /* x = 2^k z; where z is in range [Off,2*Off) and exact.
      The range is split into N subintervals.
@@ -83,7 +90,7 @@ float64x2_t VPCS_ATTR V_NAME_D1 (log) (float64x2_t x)
   k = vshrq_n_s64 (vreinterpretq_s64_u64 (tmp), 52); /* arithmetic shift.  */
   iz = vsubq_u64 (ix, vandq_u64 (tmp, d->sign_exp_mask));
   z = vreinterpretq_f64_u64 (iz);
-  e = lookup (vshrq_n_u64 (tmp, 52 - V_LOG_TABLE_BITS));
+  e = lookup (tmp);
 
   /* log(x) = log1p(z/c-1) + log(c) + k*Ln2.  */
   r = vfmaq_f64 (v_f64 (-1.0), z, e.invc);
@@ -97,9 +104,8 @@ float64x2_t VPCS_ATTR V_NAME_D1 (log) (float64x2_t x)
   p = vfmaq_f64 (A (0), A (1), r);
   y = vfmaq_f64 (y, A (4), r2);
   y = vfmaq_f64 (p, y, r2);
-  y = vfmaq_f64 (hi, y, r2);
 
-  if (__glibc_unlikely (v_any_u64 (cmp)))
-    return special_case (x, y, cmp);
-  return y;
+  if (__glibc_unlikely (v_any_u32h (cmp)))
+    return special_case (x, y, hi, r2, cmp);
+  return vfmaq_f64 (hi, y, r2);
 }