neon/rsqrte: use vmls for fallbacks.
This just lets us potentially take advantage of some optimizations in
mls without having to copy them here.
*
* Copyright:
* 2021 Zhi An Ng <zhin@google.com> (Copyright owned by Google, LLC)
+ * 2021 Evan Nemerson <evan@nemerson.com>
*/
#if !defined(SIMDE_ARM_NEON_RSQRTS_H)
#define SIMDE_ARM_NEON_RSQRTS_H
#include "types.h"
+#include "mls.h"
+#include "mul_n.h"
+#include "dup_n.h"
HEDLEY_DIAGNOSTIC_PUSH
SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
@@ -39,18 +43,14 @@ simde_vrsqrts_f32(simde_float32x2_t a, simde_float32x2_t b) {
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
return vrsqrts_f32(a, b);
#else
- simde_float32x2_private
- r_,
- a_ = simde_float32x2_to_private(a),
- b_ = simde_float32x2_to_private(b);
-
- SIMDE_VECTORIZE
- for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
- r_.values[i] = (SIMDE_FLOAT32_C(3.0) - (a_.values[i] * b_.values[i])) /
- SIMDE_FLOAT32_C(2.0);
- }
-
- return simde_float32x2_from_private(r_);
+ return
+ simde_vmul_n_f32(
+ simde_vmls_f32(
+ simde_vdup_n_f32(SIMDE_FLOAT32_C(3.0)),
+ a,
+ b),
+ SIMDE_FLOAT32_C(0.5)
+ );
#endif
}
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
@@ -64,18 +64,14 @@ simde_vrsqrtsq_f32(simde_float32x4_t a, simde_float32x4_t b) {
#if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
return vrsqrtsq_f32(a, b);
#else
- simde_float32x4_private
- r_,
- a_ = simde_float32x4_to_private(a),
- b_ = simde_float32x4_to_private(b);
-
- SIMDE_VECTORIZE
- for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
- r_.values[i] = (SIMDE_FLOAT32_C(3.0) - (a_.values[i] * b_.values[i])) /
- SIMDE_FLOAT32_C(2.0);
- }
-
- return simde_float32x4_from_private(r_);
+ return
+ simde_vmulq_n_f32(
+ simde_vmlsq_f32(
+ simde_vdupq_n_f32(SIMDE_FLOAT32_C(3.0)),
+ a,
+ b),
+ SIMDE_FLOAT32_C(0.5)
+ );
#endif
}
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
