c++ - Aliasing regular array with vector intrinsics in gcc -
i'm playing around vector instrinsics in gcc, particularly avx, , i'm tempted write vector multiply between 2 arrays: #include <unistd.h> void __attribute__((target("avx"))) vmul(float* __restrict__ cc, const float* __restrict__ aa, const float* __restrict__ bb, ssize_t size) { const ssize_t vecsize=8; typedef float vfloat __attribute__((vector_size(sizeof(float)*vecsize))); // duff's device, process remainder front ssize_t rem = size % vecsize; switch (rem) { case 7: cc[6] = aa[6]*bb[6]; /* fallthru */ case 6: cc[5] = aa[5]*bb[5]; /* fallthru */ case 5: cc[4] = aa[4]*bb[4]; /* fallthru */ case 4: cc[3] = aa[3]*bb[3]; /* fallthru */ case 3: cc[2] = aa[2]*bb[2]; /* fallthru */ case 2: cc[1] = aa[1]*bb[1]; /* fallthru */ case 1: cc[0] = aa[0]*bb[0]; /* fallthru */ case 0: break; } size -= rem; // process rest of array const vfloat *va = (const vfloat*)(...