Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

thumb2 folding of constant addresses unhelpful #6150

Open Quuxplusone opened 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR5668
Status NEW
Importance P normal
Reported by Brian G. Lucas (bagel99@gmail.com)
Reported on 2009-12-02 12:27:45 -0800
Last modified on 2017-11-13 05:57:46 -0800
Version trunk
Hardware PC Linux
CC anton@korobeynikov.info, codeman.consulting@gmail.com, evan.cheng@apple.com, llvm-bugs@lists.llvm.org, t.scheller@samsung.com
Fixed by commit(s)
Attachments const-addr.ll (522 bytes, application/octet-stream)
Blocks
Blocked by
See also
Created attachment 3907
test case

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.
Quuxplusone commented 14 years ago

Attached const-addr.ll (522 bytes, application/octet-stream): test case

Quuxplusone 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
Quuxplusone 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.

Quuxplusone 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