Negation Intrinsics

These Intel® Supplemental Streaming SIMD Extensions 3 (Intel® SSSE3) intrinsics are used for negation. The prototypes for these intrinsics are in tmmintrin.h. You can also use the ia32intrin.h header file for these intrinsics.

extern __m128i _mm_sign_epi8 (__m128i a, __m128i b);

Negate packed bytes in a if corresponding sign in b is less than zero.

Interpreting a, b, and r as arrays of signed 8-bit integers:

for (i = 0; i < 16; i++){
 if (b[i] < 0){
  r[i] =  -a[i];
 }
 else
 if (b[i] == 0){
  r[i] = 0;
 }
 else
 {
  r[i] = a[i];
 }
}

extern __m128i _mm_sign_epi16 (__m128i a, __m128i b);

Negate packed words in a if corresponding sign in b is less than zero.

Interpreting a, b, and r as arrays of signed 16-bit integers:

for (i = 0; i < 8; i++){
 if (b[i] < 0){
  r[i] =  -a[i];
 }
 else
 if (b[i] == 0){
  r[i] = 0;
 }
 else
 {
  r[i] = a[i];
 }
}

extern __m128i _mm_sign_epi32 (__m128i a, __m128i b);

Negate packed dwords in a if corresponding sign in b is less than zero.

Interpreting a, b, and r as arrays of signed 32-bit integers:

for (i = 0; i < 4; i++){
 if (b[i] < 0){
  r[i] = -a[i];
 }
 else
 if (b[i] == 0){
  r[i] = 0;
 }
 else
 {
  r[i] = a[i];
 }
}

extern __m64 _mm_sign_pi8 (__m64 a, __m64 b);

Negate packed bytes in a if corresponding sign in b is less than zero.

Interpreting a, b, and r as arrays of signed 8-bit integers:

for (i = 0; i < 16; i++){
 if (b[i] < 0){
  r[i] =  -a[i];
 }
 else
 if (b[i] == 0){
  r[i] = 0;
 }
 else
 {
  r[i] = a[i];
 }
}

extern __m64 _mm_sign_pi16 (__m64 a, __m64 b);

Negate packed words in a if corresponding sign in b is less than zero.

Interpreting a, b, and r as arrays of signed 16-bit integers:

for (i = 0; i < 8; i++){
 if (b[i] < 0){
  r[i] =  -a[i];
 }
 else
 if (b[i] == 0){
  r[i] = 0;
 }
 else
 {
  r[i] = a[i];
 }
}

extern __m64 _mm_sign_pi32 (__m64 a, __m64 b);

Negate packed dwords in a if corresponding sign in b is less than zero.

Interpreting a, b, and r as arrays of signed 32-bit integers:

for (i = 0; i < 2; i++){
 if (b[i] < 0){
  r[i] =  -a[i];
 }
 else
 if (b[i] == 0){
  r[i] = 0;
 }
 else
 {
  r[i] = a[i];
 }
}

Submit feedback on this help topic

Copyright © 1996-2011, Intel Corporation. All rights reserved.