diff options
author | Marat Dukhan <maratek@google.com> | 2019-09-27 14:51:35 -0700 |
---|---|---|
committer | Marat Dukhan <maratek@google.com> | 2019-09-27 14:51:35 -0700 |
commit | 58f1cea240b080593ee95520e4b1a381efc529ce (patch) | |
tree | f65465531c7ba09744e39a9049f1f97fd1b33b0f /include | |
parent | daa4ba3a740a861092d99897c51b70092c3a43ec (diff) | |
download | psimd-58f1cea240b080593ee95520e4b1a381efc529ce.tar.gz |
psimd_qfma_f32 function
Diffstat (limited to 'include')
-rw-r--r-- | include/psimd.h | 15 |
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); |