Intel ARCHITECTURE IA-32 User Manual
Page 206

IA-32 Intel® Architecture Optimization
3-26
In C++ (but not in C) it is also possible to force the alignment of a
class
/
struct
/
union
type, as in the code that follows:
struct __declspec(align(16)) my_m128
{
float f[4];
};
But, if the data in such a
class
is going to be used with the Streaming
SIMD Extensions or Streaming SIMD Extensions 2, it is preferable to
use a
union
to make this explicit. In C++, an anonymous
union
can be
used to make this more convenient:
class my_m128 {
union {
__m128 m;
float f[4];
};
};
In this example, because the
union
is anonymous, the names,
m
and
f
,
can be used as immediate member names of
my__m128
. Note that
__declspec(align)
has no effect when applied to a
class
,
struct
, or
union
member in either C or C++.
Alignment by Using
__m64
or
double
Data. In some cases, for better
performance, the compiler will align routines with
__m64
or
double
data to 16-bytes by default. The command-line switch,
-Qsfalign16
,
can be used to limit the compiler to only align in routines that contain
128-bit data. The default behavior is to use
-Qsfalign8
, which instructs
to align routines with 8- or 16-byte data types to 16-bytes.
For more details, see relevant Intel application notes in the Intel
Architecture Performance Training Center provided with the SDK and
the Intel® C++ Compiler User’s Guide.