Multiplication Intrinsics

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

extern __m128i _mm_maddubs_epi16 (__m128i a, __m128i b);

Multiply signed and unsigned bytes, add horizontal pair of signed words, pack saturated signed words.

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

for (i = 0; i < 8; i++) {
  r[i] = signed_saturate_to_word(a[2*i+1] * b[2*i+1] + a[2*i]*b[2*i]);
}

extern __m64 _mm_maddubs_pi16 (__m64 a, __m64 b);

Multiply signed and unsigned bytes, add horizontal pair of signed words, pack saturated signed words.

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

for (i = 0; i < 4; i++) {
  r[i] = signed_saturate_to_word(a[2*i+1] * b[2*i+1] + a[2*i]*b[2*i]);
}

extern __m128i _mm_mulhrs_epi16 (__m128i a, __m128i b);

Multiply signed words, scale and round signed dwords, pack high 16-bits.

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

for (i = 0; i < 8; i++) {
  r[i] =  (( (int32)((a[i] * b[i]) >> 14) + 1) >> 1) & 0xFFFF;
}

extern __m64 _mm_mulhrs_pi16 (__m64 a, __m64 b);

Multiply signed words, scale and round signed dwords, pack high 16-bits.

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

for (i = 0; i < 4; i++) {
  r[i] =  (( (int32)((a[i] * b[i]) >> 14) + 1) >> 1) & 0xFFFF;
}

Submit feedback on this help topic

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