IA-32 Intel® Architecture Optimization
5-18
Example 5-8 illustrates how to use MMX technology code for copying
or shuffling.
Horizontal ADD Using SSE
Although vertical computations use the SIMD performance better than
horizontal computations do, in some cases, the code must use a
horizontal operation. The
movlhps
/
movhlps
and shuffle can be used to
sum data horizontally. For example, starting with four 128-bit registers,
to sum up each register horizontally while having the final results in one
register, use the
movlhps
/
movhlps
instructions to align the upper and
lower parts of each register. This allows you to use a vertical add. With
the resulting partial horizontal summation, full summation follows
easily. Figure 5-3 schematically presents horizontal add using
movhlps/movlhps, while Example 5-9 and Example 5-10 provide the
code for this operation.
Example 5-8
Using MMX Technology Code for Copying or Shuffling
movq
mm0, [ebx]
; mm0= u1 u2
movq
mm1, [ebx]
; mm1= v1 v2
movq
mm2, mm0
; mm2= u1 u2
punpckhdq
mm0, mm1
; mm0= u1 v1
punpckldq
mm2, mm1
; mm2= u2 v2
movq
[edx], mm0
; store u1 v1
movq
[8+edx], mm2
; store u2 v2
movq
mm4, [8+ebx]
; mm4= u3 u4
movq
mm5, [8+ebx]
; mm5= v3 v4
movq
mm6, mm4
; mm6= u3 u4
punpckhdq
mm4, mm5
; mm4= u3 v3
punpckldq
mm6, mm5
; mm6= u4 v4
movq
[16+edx], mm4
; store u3 v3
movq
[24+edx], mm6
; store u4 v4
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...