aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarat Dukhan <maratek@google.com>2019-09-27 14:51:35 -0700
committerMarat Dukhan <maratek@google.com>2019-09-27 14:51:35 -0700
commit58f1cea240b080593ee95520e4b1a381efc529ce (patch)
treef65465531c7ba09744e39a9049f1f97fd1b33b0f
parentdaa4ba3a740a861092d99897c51b70092c3a43ec (diff)
downloadpsimd-58f1cea240b080593ee95520e4b1a381efc529ce.tar.gz
psimd_qfma_f32 function
-rw-r--r--include/psimd.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/psimd.h b/include/psimd.h
index 6d67d83..0aadfd1 100644
--- a/include/psimd.h
+++ b/include/psimd.h
@@ -659,6 +659,21 @@
#endif
}
+ /* Quasi-Fused Multiply-Add */
+ PSIMD_INTRINSIC psimd_f32 psimd_qfma_f32(psimd_f32 a, psimd_f32 b, psimd_f32 c) {
+ #if defined(__aarch64__) || defined(__ARM_NEON__) && defined(__ARM_FEATURE_FMA)
+ return (psimd_f32) vfmaq_f32((float32x4_t) a, (float32x4_t) b, (float32x4_t) c);
+ #elif (defined(__x86_64__) || defined(__i386__) || defined(__i686__)) && defined(__FMA__)
+ return (psimd_f32) _mm_fmadd_ps((__m128) c, (__m128) a, (__m128) b);
+ #elif (defined(__x86_64__) || defined(__i386__) || defined(__i686__)) && defined(__FMA4__)
+ return (psimd_f32) _mm_macc_ps((__m128) c, (__m128) a, (__m128) b);
+ #elif defined(__wasm__) && defined(__wasm_simd128__) && defined(__clang__)
+ return (psimd_f32) __builtin_wasm_qfma_f32x4(a, b, c);
+ #else
+ return a + b * c;
+ #endif
+ }
+
/* Vector and */
PSIMD_INTRINSIC psimd_f32 psimd_andmask_f32(psimd_s32 mask, psimd_f32 v) {
return (psimd_f32) (mask & (psimd_s32) v);