Reputation: 663
Upon defining a __m128i
variable in this manner:
__m128i a;
a.m128i_i32[0] = 65000;
I get the following error:
error: request for member ‘m128i_i32’ in ‘a’, which is of non-class type ‘__m128i {aka __vector(2) long long int}’ a.m128i_i32[0] = 65000;
I have included the followinf header files:
#include <x86intrin.h>
#include <emmintrin.h>
#include <smmintrin.h>
Upvotes: 2
Views: 2004
Reputation: 20936
Your code will work under Visual where __m128 is defined as
typedef union __declspec(intrin_type) __declspec(align(16)) __m128i {
__int8 m128i_i8[16];
__int16 m128i_i16[8];
__int32 m128i_i32[4];
__int64 m128i_i64[2];
unsigned __int8 m128i_u8[16];
unsigned __int16 m128i_u16[8];
unsigned __int32 m128i_u32[4];
unsigned __int64 m128i_u64[2];
} __m128i;
so you can access m128_i32, but under g++ __m128 is defined as
typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
and your code won't be compiled.
You can assign value by
int32_t* p = (int32_t*)&a;
p[0] = 65000;
Upvotes: 1
Reputation: 6667
m128i_i32
is MSVC specific. And you are compiling with GCC or Clang (judging by your error message). Use _mm_setr_epi32
instead.
__m128i a = _mm_setr_epi32(0, 1, 2, 3);
Upvotes: 6