SPRUI04F july 2015 – april 2023
In the following code, the _nassert tells the compiler, for every invocation of f(), that ptr is aligned to an 8-byte boundary. Such an assertion often leads to the compiler producing code which operates on multiple data values with a single instruction, also known as SIMD (single instruction multiple data) optimization.
void f(short *ptr)
{
_nassert((int) ptr % 8 == 0)
; a loop operating on data accessed by ptr
}
The following subsections describe methods you can use to ensure the data referenced by ptr is aligned. You have to employ one of these methods at every place in your code where f() is called.