We have an assert firing under Debug builds that checks for alignment. The assert is for a byte array that's loaded into a uint8x16_t
using vld1q_u8
. While the assert fires, we have not observed a SIG_BUS
.
Here's the use in code:
const byte* input = ...;
...
assert(IsAlignedOn(input, GetAlignmentOf(uint8x16_t));
uint64x2_t message = vreinterpretq_u64_u8(vld1q_u8(input));
I also tried with the following, and the assert fires for the alignment of uint8_t*
:
assert(IsAlignedOn(input, GetAlignmentOf(uint8_t*));
uint64x2_t message = vreinterpretq_u64_u8(vld1q_u8(input));
What are the alignment requirements for the byte array when loading it into a uint8x16_t
with vld1q_u8
?
In the above code, input
is a function paramter. IsAlignedOn
checks the alignment of its two arguments, ensuring the first is aligned to at least the second. GetAlignmentOf
is an abstraction that retrieves the alignment for a type or variable.
uint8x16_t
and uint64x2_t
are 128-bit ARM NEON vector datatypes that are expected to be placed in a Q register. vld1q_u8
is a NEON pseudo instruction that is expected to be compiled into VLD1.8
instruction. vreinterpretq_u64_u8
is an NEON pseudo instruction that eases use of the datatypes.