Optimizing for SIMD Integer Applications
4
4-23
Building Blocks
This section describes instructions and algorithms which implement
common code building blocks efficiently.
Absolute Difference of Unsigned Numbers
Example 4-16 computes the absolute difference of two unsigned
numbers. It assumes an unsigned packed-byte data type. Here, we make
use of the subtract instruction with unsigned saturation. This instruction
receives
UNSIGNED
operands and subtracts them with
UNSIGNED
saturation. This support exists only for packed bytes and packed words,
not for packed doublewords.
This example will not work if the operands are signed.
Note that the
psadbw
instruction may also be used in some situations;
see section “Packed Sum of Absolute Differences” for details.
Example 4-16 Absolute Difference of Two Unsigned Numbers
; Input:
;
MM0 source operand
;
MM1 source operand
; Output:
;
MM0 absolute difference of the unsigned
;
operands
movq
MM2, MM0
; make a copy of MM0
psubusb MM0, MM1
; compute difference one way
psubusb MM1, MM2
; compute difference the other way
por
MM0, MM1
; OR them together
Summary of Contents for ARCHITECTURE IA-32
Page 1: ...IA 32 Intel Architecture Optimization Reference Manual Order Number 248966 013US April 2006...
Page 220: ...IA 32 Intel Architecture Optimization 3 40...
Page 434: ...IA 32 Intel Architecture Optimization 9 20...
Page 514: ...IA 32 Intel Architecture Optimization B 60...
Page 536: ...IA 32 Intel Architecture Optimization C 22...