I have the following lines
la x14, L2
sw x13, 0(x14)
where the address of L2 is 0x2018
.
When I generate the ELF file and inspect it using objdump
, this is what I see (relevant parts only):
...
1018: auipc a4,0x1
101c: mv a4,a4
1020: sw a3,0(a4) # 2018 <L2>
...
The line at 1018 i.e. mv a4 a4
translates to addi a4, a4, 0
which is redundant. Why is this generated? Won't it still work without this line?
Does gcc have a requirement to always generate 2 instructions for the la
instruction?