need help, _mm_mullo_pi16() could not multiply big numbers.any suggestion to what i should do? just how do i multiply two 1-D arrays with big value(positive and negative)? x0,b,b1,s0,s1 are vectors (arrays) and _f, Adjust, _scale are scalar integers.
// C++ codes
int x0 = s0 + s1;
if(x0 < 0)
// MMX intrinsic codes
__m64*b1 = (__m64*)b;
t2 = _mm_mullo_pi16((_mm_sub_pi16(_mm_setzero_si64(),x0)),r0);
t0 = _mm_mullo_pi16(x0,r0);
p0 =_mm_srai_pi16(,_scale );
p1 =_mm_srai_pi16(_mm_add_pi16(t2,r1),_scale );
You can compute the lower 16 bits and the upper 16 bits of the 32-bit results separately. Afterwards, you will need to interleave them in order to get the full 32-bit results. Something like this should work:
_m128i hi = _mm_mulhi_epi16(a, b);
_m128i lo = _mm_mullo_epi16(a,b);
_m128i r0 = _mm_unpacklo_epi16(lo, hi);
_m128i r1 = _mm_unpackhi_epi16(lo,hi);
a and b contain 8 16-bit values that you would like to multiply. r0 contains the first 4 32-bit results; r1 contains the remaining 4 32-bit results. These instructions come with the SSE2 instruction set.