次のコードを奇数の動作を_mm_and_ps:でSSE組み込み -
__m128 a = _mm_setr_ps(1, 2, 3, 4);
__m128 b = _mm_set1_ps(2);
__m128 res = _mm_and_ps(a, b);
cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << endl;
cout << b[0] << " " << b[1] << " " << b[2] << " " << b[3] << endl;
cout << res[0] << " " << res[1] << " " << res[2] << " " << res[3] << endl;
cout<<endl;
cout << (1 & 2) << " " << (2 & 2) << " " << (3 & 2) << " " << (4 & 2) << endl;
結果:
1 2 3 4
2 2 2 2
0 2 2 2
0 2 2 0
はSSE演算の結果は、0 2 2 0
2 = 010, 4 = 100 => 2&4 = 0
ためすべきではありません。ドキュメントによれば
:
__m128 _mm_and_ps(__ M128 aは、__m128 b)は
ビット単位のAND及びB 4つの単精度浮動小数点値のを計算します。
R0 R1 R2 R3
A0 & B0 A1 & B1 A2 & B2 A3 & B3
「a」と「b」の中間値を表示しないのはなぜですか? –
編集をチェック..... – Blue