#include <immintrin.h>
static const unsigned char LUT[16] = { 0xE4, 0x24, 0x34, 0x04,
0x38, 0x08, 0x0C, 0x00,
0x39, 0x09, 0x0D, 0x01,
0x0E, 0x02, 0x03, 0x00 };
int main( ) {
float input[4] = { -1.0f, 2.0f, 3.0f, -4.0f };
float output[4] = {0};
__m128 data = _mm_loadu_ps( input );
__m128 mmask = _mm_cmpge_ps( data, _mm_setzero_ps( ) );
int shufctr = _mm_movemask_ps( mmask );
__m128 res = _mm_shuffle_ps( data, data, LUT[shufctr] );
_mm_storeu_ps( output, res );
}
I am meaning to use code similar to the above to left pack an array of floats that pass the compare into another but it's returning the error 'the last argument must be an 8-bit immediate.' How can I achieve this?