mirror of
https://github.com/aicodix/code.git
synced 2026-04-27 22:35:44 +00:00
added vcopysign()
This commit is contained in:
parent
778d51ac0f
commit
6cddcef660
4 changed files with 73 additions and 0 deletions
18
simd.hh
18
simd.hh
|
|
@ -1387,6 +1387,24 @@ static inline SIMD<int64_t, WIDTH> vsign(SIMD<int64_t, WIDTH> a, SIMD<int64_t, W
|
|||
return tmp;
|
||||
}
|
||||
|
||||
template <int WIDTH>
|
||||
static inline SIMD<float, WIDTH> vcopysign(SIMD<float, WIDTH> a, SIMD<float, WIDTH> b)
|
||||
{
|
||||
SIMD<float, WIDTH> tmp, negz = vdup<SIMD<float, WIDTH>>(-0.f);
|
||||
for (int i = 0; i < WIDTH; ++i)
|
||||
tmp.u[i] = (a.u[i] & ~negz.u[i]) | (negz.u[i] & b.u[i]);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <int WIDTH>
|
||||
static inline SIMD<double, WIDTH> vcopysign(SIMD<double, WIDTH> a, SIMD<double, WIDTH> b)
|
||||
{
|
||||
SIMD<double, WIDTH> tmp, negz = vdup<SIMD<double, WIDTH>>(-0.);
|
||||
for (int i = 0; i < WIDTH; ++i)
|
||||
tmp.u[i] = (a.u[i] & ~negz.u[i]) | (negz.u[i] & b.u[i]);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <int WIDTH>
|
||||
static inline SIMD<uint8_t, WIDTH> vshuf(SIMD<uint8_t, WIDTH> a, SIMD<uint8_t, WIDTH> b)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue