llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.64k stars 11.37k forks source link

thumb2 folding of constant addresses unhelpful #6040

Open llvmbot opened 14 years ago

llvmbot commented 14 years ago
Bugzilla Link 5668
Version trunk
OS Linux
Attachments test case
Reporter LLVM Bugzilla Contributor
CC @asl

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.

llvmbot commented 6 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

llvmbot commented 6 years ago

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.

llvmbot commented 10 years ago

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