Fast Conversion Of Signed Words To Floating-Point; Use Mmx Pxor To Negate 3Dnow! Data - AMD Athlon Processor x86 Optimization Manual

X86 code optimization
Table of Contents

Advertisement

22007E/0—November 1999

Fast Conversion of Signed Words to Floating-Point

Use MMX™ PXOR to Negate 3DNow!™ Data
Fast Conversion of Signed Words to Floating-Point
In many applications there is a need to quickly convert data
consisting of packed 16-bit signed integers into floating-point
numbers. The following two examples show how this can be
accomplished efficiently on AMD processors.
The first example shows how to do the conversion on a processor
that supports AMD 's 3 DN ow! ex te n si on s, such as t h e
AMD Athlon processor. It demonstrates the increased
efficiency from using the PI2FW instruction. Use of this
instruction should only be for AMD Athlon processor specific
code. See the AMD Extensions to the 3DNow!™ and MMX™
Instruction Set Manual, order #22466 for more information on
this instruction.
The second example demonstrates how to accomplish the same
task in blended code that achieves good performance on the
AMD Athlon processor as well as on the AMD-K6 family
processors that support 3DNow! technology.
Example 1 (AMD Athlon specific code using 3DNow! DSP extension):
MOVD
MM0, [packed_sword]
PUNPCKLWD MM0, MM0
PI2FW
MM0, MM0
MOVQ
[packed_float], MM0
Example 2 (AMD-K6 Family and AMD Athlon processor blended code):
MOVD
MM1, [packed_sword]
PXOR
MM0, MM0
PUNPCKLWD MM0, MM1
PSRAD
MM0, 16
PI2FD
MM0, MM0
MOVQ
[packed_float], MM0
For both the AMD Athlon and AMD-K6 processors, it is
recommended that code use the MMX PXOR instruction to
change the sign bit of 3DNow! operations instead of the 3DNow!
PFMUL instruction. On the AMD Athlon processor, using
PXOR allows for more parallelism, as it can execute in either
the FADD or FMUL pipes. PXOR has an execution latency of
two, but because it is a MMX instruction, there is an initial one
AMD Athlon™ Processor x86 Code Optimization
;0 0 | b a
;b b | a a
;xb=float(b) | xa=float(a)
;store xb | xa
;0 0 | b a
;0 0 | 0 0
;b 0 | a 0
;sign extend: b | a
;xb=float(b) | xa=float(a)
;store xb | xa
113

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Athlon Processor x86 and is the answer not in the manual?

Questions and answers

Table of Contents