Bit-wise select function in SSE version 2 Return the parameter arg_false bit where the parameter mask is 0x0, return the parameter arg_true bit where the mask is 1. Algorithm Explanation: Uses the identities: x XOR 0 = x x XOR x = 0 select = ((arg_true XOR arg_false) AND mask) XOR arg_false When mask = 0, the expression evaluates to: = ((arg_true XOR arg_false) AND 0x0) XOR arg_false = 0x0 XO
| 147 | // solution requires two registers. |
| 148 | // |
| 149 | inline __m128 sseSelect(const __m128& mask, const __m128& arg_true, const __m128& arg_false) |
| 150 | { |
| 151 | return _mm_xor_ps( // bit-wise XOR of arg_false, (...) |
| 152 | arg_false, |
| 153 | _mm_and_ps( // bit-wise AND of mask, (...) |
| 154 | mask, |
| 155 | _mm_xor_ps( arg_true, arg_false ) ) ); // bit-wise XOR of arg_true, arg_false |
| 156 | } |
| 157 | |
| 158 | // Coefficients of Chebyshev (minimax) degree 5 polynomial |
| 159 | // approximation to log2() over the range [1.0, 2.0[. |
no outgoing calls
no test coverage detected