cgccclangarm64raspberry-pi4

On RPi 4 GCC and CLANG use 16-bit loads


This is simplified from a larger example.

In the C source, I have:

uint32_t xx = oxdeadbeef ;

I compiled with gcc -O or clang -O

Looking at 'objdump -d a.out' on the RPi 4, I see

9ac:    5297dde8    mov w8, #0xbeef // #48879
9b0:    72bbd5a8    movk w8, #0xdead, lsl #16

This produces the correct result, but, these are 16-bit values. How do I force gcc or clang to use 32-bits in this case?

mov w8, #0xdeadbeef

Or, do I want to?


Solution

  • This micro does not have the move immediate 32-bit value into the register, only 16 bits. 2 instructions are faster and shorter than storing the value in memory and loading it into the register from memory.

    That's the reason why you have 2 instructions.