当使用 SSE2 内部函数进行按位操作时,必须将指针从int*
to 转换为__m128i*
. 此代码是否违反严格的别名规则?
void bit_twiddling_func(int size, int const* input, int* output) {
const __m128* x = (const __m128*)input;
const __m128* y = (const __m128*)output;
for (int i=0; i < size/4; ++i, ++x, ++y) {
__m128i x4 = _mm_load_si128(x); // load 4 integers
// do some bit twiddling
_mm_store_si128(y, x4); // store 4 integers
}
}
谢谢!