Take Advantage of the FSINCOS Instruction
105
22007E/0—November 1999
AMD Athlon™ Processor x86 Code Optimization
Since out-of-range arguments are extremely uncommon, the
conditional branch will be perfectly predicted, and the other
instructions used to guard the trigonometric instruction can
execute in parallel to it.
Take Advantage of the FSINCOS Instruction
Frequently, a piece of code that needs to compute the sine of an
argument also needs to compute the cosine of that same
argument. In such cases, the FSINCOS instruction should be
used to compute both trigonometric functions concurrently,
which is faster than using separate FSIN and FCOS instructions
to accomplish the same task.
Example 1 (Avoid):
FLD
QWORD PTR [x]
FLD
DWORD PTR [two_to_the_63]
FCOMIP ST,ST(1)
JBE
$in_range
CALL
$reduce_range
$in_range:
FLD
ST(0)
FCOS
FSTP
QWORD PTR [cosine_x]
FSIN
FSTP
QWORD PTR [sine_x]
Example 2 (Preferred):
FLD
QWORD PTR [x]
FLD
DWORD PTR [two_to_the_63]
FCOMIP ST,ST(1)
JBE
$in_range
CALL
$reduce_range
$in_range:
FSINCOS
FSTP
QWORD PTR [cosine_x]
FSTP
QWORD PTR [sine_x]
Summary of Contents for Athlon Processor x86
Page 1: ...AMD Athlon Processor x86 Code Optimization Guide TM...
Page 12: ...xii List of Figures AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 16: ...xvi Revision History AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 202: ...186 Page Attribute Table PAT AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 252: ...236 VectorPath Instructions AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...
Page 256: ...240 Index AMD Athlon Processor x86 Code Optimization 22007E 0 November 1999...