Reputation: 11
i want to extract the value(first word 16bits) from 128bit register, i got this command but this is not working.there will be some arithmetic operation after setting the value of a, than there will be some arithmetic operation as result inside the variable will change finally i want extract the first word...how can i do this...
int r;
int inm=0;
__m128i a=_mm_setr_epi16(8,9,3,2,4,5,6,11);
_asm{
r = _mm_extract_epi16(a,inm);
}
Upvotes: 1
Views: 780
Reputation: 30449
The pextrw
instruction does only work with an immediate value. In C this means the value needs to be a compile time constant.
int r;
static const int inm=0;
__m128i a=_mm_setr_epi16(8,9,3,2,4,5,6,11);
r = _mm_extract_epi16(a,inm);
Upvotes: 6
Reputation: 30031
You don't put intrinsics inside an _asm block. They behave just like any other function. This will work fine:
#include <emmintrin.h>
__m128i a = _mm_setr_epi16(8,9,3,2,4,5,6,11);
int r = _mm_extract_epi16(a, 0);
Upvotes: 8