https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212

--- Comment #76 from Kazumoto Kojima <kkojima at gcc dot gnu.org> ---
Created attachment 33787
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33787&action=edit
a reduced test case of SCiBE compiler/vam test

compiler/vam is a test which is an example of code size regression
from non LRA compiler.  With -O2, non LRA compiler generates code like

    mov.l    r0,@(56,r15)
    mov    #64,r1
    add    #2,r0
    mov    r13,r2
    add    r15,r1
    mov.l    r0,@(60,r15)
    add    #18,r2
    mov    r13,r14
    add    #2,r0
    mov.l    r2,@(0,r1)
    mov.l    r0,@(4,r1)
    add    #2,r2
    add    #2,r0
    mov.l    r2,@(8,r1)
    mov.l    r0,@(12,r1)

and the corresponding code generated by sh-lra compiler looks like

    mov.l    r1,@(56,r15)
    mov    #17,r1
    add    r2,r1
    mov.l    r1,@(60,r15)
    mov    #2,r14
    mov    #16,r10
    mov    #18,r1
    add    r2,r1
    add    r2,r14
    add    r2,r10
    mov    #64,r2
    add    r15,r2
    mov.l    r1,@r2
    mov    #19,r1
    mov    #68,r2
    add    r13,r1
    add    r15,r2
    mov.l    r1,@r2
    mov    #20,r1
    mov    #72,r2
    add    r13,r1
    add    r15,r2
    mov.l    r1,@r2
    mov    #21,r1
    mov    #76,r2
    add    r13,r1
    add    r15,r2
    mov.l    r1,@r2

which shows that base+disp addressing mode wasn't used for the insn
(set reg (mem (plus sp N))) when N >= 64.
It looks that non LRA compiler uses targetm.legitimize_address to
handle that case and splits it to (set new_reg (plus sp M)) and
(set reg (mem (plus new_reg N-M))) so as to N-M is a legitimate
display constant for base+disp addressing.

Reply via email to