
114
Chapter 3: General-Purpose Programming
AMD 64-Bit Technology
24593—Rev. 3.09—September 2003
instructions are committed. Implementations can also
speculatively
execute instructions—executing instructions
before knowing their results will be used (for example,
executing both sides of a branch). By executing instructions
out-of-order and speculatively, a processor can boost
application performance by executing instructions that are
ready, rather than delaying them behind instructions that are
waiting for data. However, the processor commits results in
program order (the order expected by software).
When executing instructions out-of-order and speculatively,
processor implementations often find it useful to also allow out-
of-order and speculative memory accesses. However, such
memory accesses are potentially visible to software and system
devices. The following sections describe the architectural rules
for memory accesses. See “Memory System” in Volume 2 for
information on how system software can further specify the
flexibility of memory accesses.
Read Ordering.
The ordering of memory reads does not usually
affect program execution because the ordering does not usually
affect the state of software-visible resources. The rules
governing read ordering are:
Out-of-order reads are allowed.
Out-of-order reads can occur as
a result of out-of-order instruction execution. The processor
can
read
memory
out-of-order
instructions that are executed out-of-order.
Speculative reads are allowed.
A speculative read occurs when
the processor begins executing a memory-read instruction
before it knows whether the instruction’s result will actually
be needed. For example, the processor can predict a branch
to occur and begin executing instructions following the
predicted branch, before it knows whether the prediction is
valid. When one of the speculative instructions reads data
from memory, the read itself is speculative.
Reads can usually be reordered ahead of writes.
Reads are
generally given a higher priority by the processor than
writes because instruction execution stalls if the read data
required by an instruction is not immediately available.
Allowing reads ahead of writes usually maximizes software
performance.
Reads can be reordered ahead of writes, except that a read
cannot
be reordered ahead of a prior write if the read is from
to
prevent
stalling