Open llvmbot opened 14 years ago
Assuming a constant needs the pair, the ARM assembly spec defines the MOV32 pseudo to allow nice display of the operand, and I've always wondered why we didn't use it.
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489f/Cjagdjbf.html
I noticed this a long time ago. When Thumb2 is active (at least) the movw/movt appears to take precedence over the displacement. That is probably fine for O2 and such since I think the pair is pipelined into a single load on proc, but the extra code caused would hurt other cases.
This still reproduces just fine with ToT (r212922):
movw r0, #​49160
movw r1, #​49156
movt r0, #​1039
movt r1, #​1039
ldr r0, [r0]
ldr r1, [r1]
add r0, r1
movw r1, #​49164
movt r1, #​1039
ldr r1, [r1]
add r0, r1
bx lr
Extended Description
When addresses are a displacement from a constant (this can happen in device drivers), the resulting address gets folded rather than using base+displacement addressing. This results in code bloat.