Packed max/min of signed word and unsigned byte, Signed word, Signed word -29 – Intel ARCHITECTURE IA-32 User Manual

Page 249: Example 4-22

Advertising
background image

Optimizing for SIMD Integer Applications

4

4-29

packed-subtract instructions with unsigned saturation, thus this
technique can only be used on packed-bytes and packed-words data
types.

The example illustrates the operation on word values.

Packed Max/Min of Signed Word and Unsigned Byte

Signed Word

The

pmaxsw

instruction returns the maximum between the four signed

words in either two SIMD registers, or one SIMD register and a
memory location.

The

pminsw

instruction returns the minimum between the four signed

words in either two SIMD registers, or one SIMD register and a
memory location.

Example 4-22 Clipping to an Arbitrary Unsigned Range [high, low]

; Input:

;

MM0

unsigned source operands

; Output:

;

MM1

unsigned operands clipped to the unsigned

;

range [HIGH, LOW]

paddusw

MM0, 0xffff - high

; in effect this clips to high

psubusw

MM0, (0xffff - high + low)

; in effect this clips to low

paddw

MM0, low

; undo the previous two offsets

Advertising