What does alignment to 16-byte boundary mean in x86

前端 未结 3 1213
暖寄归人
暖寄归人 2020-12-30 15:12

Intel\'s official optimization guide has a chapter on converting from MMX commands to SSE where they state the fallowing statment:

Computation instruc

相关标签:
3条回答
  • 2020-12-30 15:33

    Certain SIMD instructions, which perform the same instruction on multiple data, require that the memory address of this data is aligned to a certain byte boundary. This effectively means that the address of the memory your data resides in needs to be divisible by the number of bytes required by the instruction.

    So in your case the alignment is 16 bytes (128 bits), which means the memory address of your data needs to be a multiple of 16. E.g. 0x00010 would be 16 byte aligned, while 0x00011 would not be.

    How to get your data to be aligned depends on the programming language (and sometimes compiler) you are using. Most languages that have the notion of a memory address will also provide you with means to specify the alignment.

    0 讨论(0)
  • 2020-12-30 15:34

    Data that's aligned on a 16 byte boundary will have a memory address that's an even number — strictly speaking, a multiple of two. Each byte is 8 bits, so to align on a 16 byte boundary, you need to align to each set of two bytes.

    Similarly, memory aligned on a 32 bit (4 byte) boundary would have a memory address that's a multiple of four, because you group four bytes together to form a 32 bit word.

    0 讨论(0)
  • 2020-12-30 15:49

    I'm guessing here, but could it be that "may not be aligned to a 16-byte boundary" means that this memory location has been aligned to a smaller value (4 or 8 bytes) before for some other purposes and now to execute SSE instructions on this memory you need to load it into a register explicitly?

    0 讨论(0)
提交回复
热议问题