Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有四个压缩整数。
__m128i val = _mm_set_epi32(42,64,123,456);
翻转val中四个整数的符号(乘以-1)的最快方法是什么?
您可以从一组{0,0,0,0}[这可能是最快的] 中减去您的实际值,您可以使用 {-1,-1,-1,-1} “all one”进行异或,然后添加 {1,1,1,1} . 或者你可以乘以-1。
{0,0,0,0}
只需从 0 中减去,例如
val = _mm_sub_epi32(_mm_set1_epi32(0), val);