I'm working with a function on the critical path. The code looks like so:
void ProcessData(const byte* input, size_t size)
{
ALIGN_ARRAY(16) int32_t m0[2] = { ((const int32_t*)input)[0] };
ALIGN_ARRAY(16) int32_t m1[2] = { ((const int32_t*)input)[1] };
...
}
The first element, m0[0]
is the one I care about. The second element, m0[1]
is scratch space and keeps things aligned before m
is shipped off to the SIMD engine. m0[1]
will be populated with a value, but I don't need it initialized.
This code is called repeatedly and very influential on benchmarking results, so its important to minimize everything. I want the compiler to know it can initialize the first element because the code may be better optimized.
How do I ensure only the first element is initialized, and the remaining elements in the array are uninitialized? Is it even possible?
This question is opposite of questions like Initialization of a normal array with one default value, Static array initialization of individual elements in C++ and Array initialization with {0}, {0,}?
I'm also aware that initialization is different than assignment; and some of the details of zero-, default- and value-initialization and how PODs affect it.