Chapter 5 Cache and Memory Optimizations 95
Software Optimization Guide for AMD64 Processors
25112 Rev. 3.06 September 2005
5.2 Natural Alignment of Data Objects
Optimization
❖ Make sure data objects are naturally aligned. An object is naturally aligned if it is located at an
address that is a multiple of its size.
Application
This optimization applies to:
• 32-bit software
• 64-bit software
Rationale
A misaligned store or load operation suffers a minimum one-cycle penalty in the processor’s load-
store pipeline. Also, using misaligned loads and stores increases the likelihood of encountering a
store-to-load forwarding pitfall, especially when operating in long mode (64-bit software). (For a
more detailed discussion of store-to-load forwarding issues, see “Store-to-Load Forwarding
Restrictions” on page 100.)
In addition, if the Alignment Mask bit is set in Control Register 0 (CR0), an unaligned memory
reference may cause an alignment check exception. For more information on this topic, see Volume 2
of the AMD64 Architecture Programmer’s Manual (order# 24593).
Locate this type of object At an address evenly divisible by
Word 2
Doubleword 4
Quadword 8
Ten-byte (for example, TBYTE or REAL10) 8 (instead of 10)
Double quadword 16