diff options
author | Marat Dukhan <marat@fb.com> | 2018-09-06 18:49:25 +0300 |
---|---|---|
committer | Marat Dukhan <marat@fb.com> | 2018-09-06 18:49:25 +0300 |
commit | 9efe01e71c2bafc176ca2351e475ef9c2d44aa06 (patch) | |
tree | 81b2c90125e789878c4a231762ec3900012d3197 /include | |
parent | 0abf73c30911c8cb4e8624b2e02c320f2744783f (diff) | |
download | psimd-9efe01e71c2bafc176ca2351e475ef9c2d44aa06.tar.gz |
Add psimd_s32->psimd_f32 conversion function
Diffstat (limited to 'include')
-rw-r--r-- | include/psimd.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/psimd.h b/include/psimd.h index b280d97..4792766 100644 --- a/include/psimd.h +++ b/include/psimd.h @@ -743,6 +743,18 @@ #endif } + PSIMD_INTRINSIC psimd_f32 psimd_cvt_s32_f32(psimd_s32 v) { + #if defined(__clang__) + return __builtin_convertvector(v, psimd_f32); + #elif defined(__ARM_NEON__) || defined(__ARM_NEON) + return (psimd_f32) vcvtq_f32_s32((int32x4_t) v); + #elif defined(__SSE2__) + return (psimd_f32) _mm_cvtepi32_ps((__m128i) v); + #else + return (psimd_f32) { (float) v[0], (float) v[1], (float) v[2], (float) v[3] }; + #endif + } + /* Broadcast vector element */ #if defined(__clang__) PSIMD_INTRINSIC psimd_f32 psimd_splat0_f32(psimd_f32 v) { |