The argument for _mm_store_si128
must be 16 byte-aligned. A randomly chosen element of an int-array will only be sizeof(int)-aligned (even if the array itself is 16 byte-aligned). So you must make sure that the index into the array is a multiple of (16/sizeof(int))
, e.g. like so:
__m128i * index = (__m128i *) &array[(RANDOMNUMBER / (16/sizeof(int))) * (16/sizeof(int))];
This will guarantee that the write will be properly aligned. Whether this is what your code really needs to do is another question...