13.07.2015 Views

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

OPTIMIZING FOR SIMD INTEGER APPLICATIONS5.6.1 Absolute Difference of Unsigned NumbersExample 5-18 computes the absolute difference of two unsigned numbers. Itassumes an unsigned packed-byte data type.Here, we make use of the subtract instruction with unsigned saturation. This instructionreceives UNSIGNED oper<strong>and</strong>s <strong>and</strong> subtracts them with UNSIGNED saturation.This support exists only for packed bytes <strong>and</strong> packed words, not for packed doublewords.Example 5-18. Absolute Difference of Two Unsigned Numbers; Input:; MM0 source oper<strong>and</strong>; MM1 source oper<strong>and</strong>; Output:; MM0absolute difference of the unsigned; oper<strong>and</strong>smovq mm2, mm0 ; make a copy of mm0psubusbmm0, mm1 ; compute difference one waypsubusbmm1, mm2 ; compute difference the other waypor mm0, mm1 ; OR them togetherThis example will not work if the oper<strong>and</strong>s are signed. Note that PSADBW may alsobe used in some situations. See Section 5.6.9 for details.5.6.2 Absolute Difference of Signed NumbersExample 5-19 computes the absolute difference of two signed numbers using SSSE3instruction PABSW. This sequence is more efficient than using previous generation ofSIMD instruction extensions.Example 5-19. Absolute Difference of Signed Numbers;Input:; XMM0 signed source oper<strong>and</strong>; XMM1 signed source oper<strong>and</strong>;Output:; XMM1absolute difference of the unsigned; oper<strong>and</strong>spsubw xmm0, xmm1 ; subtract wordspabsw xmm1, xmm0 ; results in XMM15-20

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!