
Software Optimization Guide for AMD64 Processors | 25112 Rev. 3.06 September 2005 |
6.2Two-Byte Near-Return RET Instruction
Optimization
Use of a
•Any kind of branch (either conditional or unconditional) that has the
•A conditional branch that occurs in the code directly before the
Application
This optimization applies to:
•
•
Rationale
The processor is unable to apply a branch prediction to the
The easiest way to assure the utilization of the branch prediction mechanism is to use a
REPRET TEXTEQU <DB 0F3h, 0C3h>
Examples
Avoid branches in which the target of the branch is a
jmp label | ; | Jump to a |
... |
|
|
label: |
|
|
ret | ; | RET is potentially mispredicted. |
Avoid branches that immediately precede a
jz label | ; Conditional branch is | not taken. | |
ret | ; | RET is a | instruction, |
| ; | potentially mispredicted. | |
128 | Branch Optimizations | Chapter 6 |