aligned_mem_access.c 343 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <stdio.h>
#include <immintrin.h>

__m128 mvec   = {1.0, 2.0, 3.0, 42.0};
float  fvec[] = {.0, .0, .0, .0};

/* Uses movaps instruction to move data between XMMn <-> mem. Fails
 * with segfault when data section is not properly aligned (16 byte).
 */
long foo(void)
{
        _mm_store_ps(fvec, mvec);
        return (long) fvec[3];
}