| 1620 | } |
| 1621 | |
| 1622 | inline void VecPositiveFloorCeilScalar(const vec_float& v, vec_float *f, vec_float *c) |
| 1623 | { |
| 1624 | #if defined(TERATHON_SSE) |
| 1625 | |
| 1626 | #if defined(TERATHON_SSE4) |
| 1627 | |
| 1628 | *f = _mm_round_ps(v, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); |
| 1629 | *c = _mm_round_ps(v, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); |
| 1630 | |
| 1631 | #else |
| 1632 | |
| 1633 | const vec_float one = VecLoadVectorConstant<0x3F800000>(); |
| 1634 | const vec_float two23 = VecLoadVectorConstant<0x4B000000>(); |
| 1635 | |
| 1636 | vec_float result = _mm_sub_ss(_mm_add_ss(v, two23), two23); |
| 1637 | *f = _mm_sub_ss(result, _mm_and_ps(one, _mm_cmplt_ps(v, result))); |
| 1638 | *c = _mm_add_ss(result, _mm_and_ps(one, _mm_cmplt_ps(result, v))); |
| 1639 | |
| 1640 | #endif |
| 1641 | |
| 1642 | #elif defined(TERATHON_NEON) |
| 1643 | |
| 1644 | const vec_uint32 one = vdupq_n_u32(0x3F800000); |
| 1645 | const vec_float two23 = vdupq_n_f32(8388608.0F); |
| 1646 | |
| 1647 | vec_float result = vsubq_f32(vaddq_f32(v, two23), two23); |
| 1648 | *f = vsubq_f32(result, vreinterpretq_f32_u32(vandq_u32(one, vcltq_f32(v, result)))); |
| 1649 | *c = vaddq_f32(result, vreinterpretq_f32_u32(vandq_u32(one, vcltq_f32(result, v)))); |
| 1650 | |
| 1651 | #endif |
| 1652 | } |
| 1653 | |
| 1654 | inline void VecNegativeFloorCeil(const vec_float& v, vec_float *f, vec_float *c) |
| 1655 | { |