diff options
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); |