Reputation: 37
Then what I mean is that I want to split each 32-bit unsigned int into four 8-bit. The corresponding bit not change.
If the uint32x4_t
is:
01000101001111100000001000010000 | 01000101001111100000001000010000 | 01000101001111100000001000010000 | 01000101001111100000001000010000
I want to get:
01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 |
How can I do this?
Upvotes: 1
Views: 993
Reputation: 17492
With vreinterpretq_u8_u32
. The prototype is:
uint8x16_t vreinterpretq_u8_u32 (uint32x4_t a);
Edit: as @EOF pointed out in the comment below, you may need an endian swap (vrev32q_u8
) too. GCC and clang define __BYTE_ORDER__
(to __ORDER_LITTLE_ENDIAN__
for little-endian and __ORDER_BIG_ENDIAN__
for big-endian), or if you need something a bit more portable see https://github.com/nemequ/portable-snippets/tree/master/endian
Upvotes: 2