Intel ARCHITECTURE IA-32 Reference Manual page 205

Architecture optimization
Table of Contents

Advertisement

The
__declspec(align(16))
declarations to force 16-byte alignment. This is particularly useful for
local or global data declarations that are assigned to 128-bit data types.
The syntax for it is
__declspec(align(integer-constant))
where the
integer-constant
than 32. For example, the following increases the alignment to 16-bytes:
__declspec(align(16)) float buffer[400];
The variable
buffer
type
or
__m128
F32vec4
object,
, will occur with aligned data.
F32vec4
x
void foo() {
F32vec4 x = *(__m128 *) buffer;
...
}
Without the declaration of
Alignment by Using a
can be used with 128-bit data types to allow the compiler to align
union
the data structure by default. Doing so is preferred to forcing alignment
with
__declspec(align(16))
intent to the compiler in that
union {
float f[400];
__m128 m[100];
} buffer;
The 16-byte alignment is used by default due to the
; it is not necessary to use
union
specifications can be placed before data
is an integral power of two but no greater
could then be used as if it contained 100 objects of
. In the code below, the construction of the
__declspec(align(16))
Structure. Preferably, when feasible, a
union
because it exposes the true program
data is being used. For example:
__m128
__declspec(align(16))
Coding for SIMD Architectures
, a fault may occur.
type in the
__m128
to force it.
3
3-25

Advertisement

Table of Contents
loading

Table of Contents