rsimd

Make SIMD instruction sets easier to use
git clone git://git.meso-star.fr/rsimd.git
Log | Files | Refs | README | LICENSE

commit 6bae6e6f731b286e23125001a398af196ce30418
parent 0fb13274b16cf1ec799918a322615201973929a2
Author: vaplv <vaplv@free.fr>
Date:   Mon, 27 Oct 2014 15:18:42 +0100

Add and test the soa4f<2|3|4>_sel functions

Diffstat:
Msrc/soa4fX.h | 12++++++++++++
Msrc/test_soa4f2.c | 3+++
Msrc/test_soa4f3.c | 4++++
Msrc/test_soa4f4.c | 7+++++++
4 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/soa4fX.h b/src/soa4fX.h @@ -313,6 +313,18 @@ SOA4FX_FUNC__(min)(v4f_T* dst, const v4f_T* a, const v4f_T* b) return SOA4FX_FUNC__(set__)(dst, tmp); } +static FINLINE v4f_T* +SOA4FX_FUNC__(sel) + (v4f_T* dst, const v4f_T* vfalse, const v4f_T* vtrue, const v4f_T cond) +{ + v4f_T tmp[SOA4FX_DIMENSION__]; + int i; + ASSERT(dst && vfalse && vtrue); + FOR_EACH(i, 0, SOA4FX_DIMENSION__) + tmp[i] = v4f_sel(vfalse[i], vtrue[i], cond); + return SOA4FX_FUNC__(set__)(dst, tmp); +} + #undef SIZEOF_SOA4FX__ #undef SOA4FX_DIMENSION__ #undef SOA4FX_FUNC__ diff --git a/src/test_soa4f2.c b/src/test_soa4f2.c @@ -106,6 +106,9 @@ main(int argc, char** argv) CHECK(soa4f2_max(dst, a, b), dst); CHECK_F2(dst, 3.f, 2.f, 3.f, -1.f, 1.f, 0.f, 0.5f, 2.f); + soa4f2_sel(dst, b, a, v4f_mask(~0, ~0, 1, ~0)); + CHECK_F2(dst, 1.f, 2.f, 1.f, -1.f, -2.f, 0.f, 0.5f, 0.f); + return 0; } diff --git a/src/test_soa4f3.c b/src/test_soa4f3.c @@ -135,6 +135,10 @@ main(int argc, char** argv) CHECK_F3(dst, 1.f, 2.f, 1.f, -2.f,-2.f,-6.f,-7.f, 0.f,-1.f, 1.f, 0.f, 2.f); CHECK(soa4f3_max(dst, a, b), dst); CHECK_F3(dst, 3.f, 2.f, 3.f, -1.f, 1.f, 0.f, 0.5f, 2.f, 0.f, 4.f, 3.f, 3.f); + + soa4f3_sel(dst, b, a, v4f_mask(~0, ~0, 1, ~0)); + CHECK_F3(dst, 1.f, 2.f, 1.f, -1.f, -2.f, 0.f, 0.5f, 0.f, -1.f, 4.f, 0.f, 2.f); + return 0; } diff --git a/src/test_soa4f4.c b/src/test_soa4f4.c @@ -195,5 +195,12 @@ main(int argc, char** argv) 0.f, 4.f, 3.f, 3.f, 1.f, 7.f, 0.5f, 0.f); + soa4f4_sel(dst, b, a, v4f_mask(~0, ~0, 1, ~0)); + CHECK_F4(dst, + 1.f, 2.f, 1.f, -1.f, + -2.f, 0.f, 0.5f, 0.f, + -1.f, 4.f, 0.f, 2.f, + -5.f, 7.f, 0.f, -1.f); + return 0; }