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

--- Comment #11 from Mikael Pettersson <mikpelinux at gmail dot com> ---
The problematic BB looks equivalent with and without -mlra in .324r.ira:

(code_label 44 97 45 11 7 (nil) [1 uses])
(note 45 44 89 11 [bb 11] NOTE_INSN_BASIC_BLOCK)
(insn 89 45 47 11 (set (reg/v/f:SI 43 [ ap ])
        (reg/v/f:SI 41 [ D.1967 ])) "/tmp/pr120165-1.c":34:18 55 {*movsi_m68k2}
     (expr_list:REG_DEAD (reg/v/f:SI 41 [ D.1967 ])
        (nil)))
(insn 47 89 48 11 (set (mem:SI (pre_dec:SI (reg/f:SI 15 %sp)) [1  S4 A16])
        (mem:SI (post_inc:SI (reg/v/f:SI 43 [ ap ])) [1 MEM[(int *)ap_30]+0 S4
A16])) "/tmp/pr120165-1.c":34:18 discrim 1 55 {*movsi_m68k2}
     (expr_list:REG_INC (reg/v/f:SI 43 [ ap ])
        (expr_list:REG_ARGS_SIZE (const_int 4 [0x4])
            (nil))))
(note 48 47 49 11 NOTE_INSN_DELETED)
(call_insn 49 48 91 11 (set (reg:SI 0 %d0)
        (call (mem:QI (symbol_ref:SI ("target") [flags 0x41]  <function_decl
0x7fdffd9e8200 target>) [0 target S1 A8])
            (const_int 4 [0x4]))) "/tmp/pr120165-1.c":34:18 discrim 1 394
{*symbolic_call_value_jsr}
     (expr_list:REG_CALL_DECL (symbol_ref:SI ("target") [flags 0x41] 
<function_decl 0x7fdffd9e8200 target>)
        (nil))
    (expr_list:BLK (use (mem:BLK (reg/f:SI 15 %sp) [0  S4 A8]))
        (nil)) 0)
...

But .325r.reload shows a major difference.

Without -mlra we have

(code_label 44 97 45 11 7 (nil) [1 uses])
(note 45 44 89 11 [bb 11] NOTE_INSN_BASIC_BLOCK)
(insn 89 45 104 11 (set (mem/f/c:SI (plus:SI (reg/f:SI 15 %sp)
                (const_int 20 [0x14])) [2 ap+0 S4 A32])
        (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])) "/tmp/pr120165-1.c":34:18 55
{*movsi_m68k2}
     (nil))
(insn 104 89 105 11 (set (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])
        (plus:SI (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])
            (const_int 4 [0x4]))) "/tmp/pr120165-1.c":34:18 discrim 1 150
{*addsi3_internal}
     (nil))
(insn 105 104 106 11 (set (mem/f/c:SI (plus:SI (reg/f:SI 15 %sp)
                (const_int 20 [0x14])) [2 ap+0 S4 A32])
        (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])) "/tmp/pr120165-1.c":34:18
discrim 1 54 {*movsi_m68k}
     (nil))
(insn 106 105 47 11 (set (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])
        (plus:SI (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])
            (const_int -4 [0xfffffffffffffffc]))) "/tmp/pr120165-1.c":34:18
discrim 1 150 {*addsi3_internal}
     (nil))
(insn 47 106 48 11 (set (mem:SI (pre_dec:SI (reg/f:SI 15 %sp)) [1  S4 A16])
        (mem:SI (post_inc:SI (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])) [1
MEM[(int *)ap_30]+0 S4 A16])) "/tmp/pr120165-1.c":34:18 discrim 1 55
{*movsi_m68k2}
     (expr_list:REG_INC (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])
        (expr_list:REG_ARGS_SIZE (const_int 4 [0x4])
            (nil))))
(note 48 47 49 11 NOTE_INSN_DELETED)
(call_insn 49 48 50 11 (set (reg:SI 0 %d0)
        (call (mem:QI (symbol_ref:SI ("target") [flags 0x41]  <function_decl
0x7f21d3f3a200 target>) [0 target S1 A8])
            (const_int 4 [0x4]))) "/tmp/pr120165-1.c":34:18 discrim 1 394
{*symbolic_call_value_jsr}
     (expr_list:REG_CALL_DECL (symbol_ref:SI ("target") [flags 0x41] 
<function_decl 0x7f21d3f3a200 target>)
        (nil))
    (expr_list:BLK (use (mem:BLK (reg/f:SI 15 %sp) [0  S4 A8]))
        (nil)) 0)
...

i.e., save ap (redundant), increment ap, save incremented ap, decrement ap,
fetch ap and push, call.

Whereas with -mlra it becomes

(code_label 44 97 45 11 7 (nil) [1 uses])
(note 45 44 89 11 [bb 11] NOTE_INSN_BASIC_BLOCK)
(insn 89 45 105 11 (set (mem/f/c:SI (plus:SI (reg/f:SI 15 %sp)
                (const_int 20 [0x14])) [2 ap+0 S4 A32])
        (reg/v/f:SI 8 %a0 [orig:41 D.1967 ] [41])) "/tmp/pr120165-1.c":34:18 55
{*movsi_m68k2}
     (nil))
(insn 105 89 47 11 (set (reg/f:SI 8 %a0 [53])
        (mem/f/c:SI (plus:SI (reg/f:SI 15 %sp)
                (const_int 20 [0x14])) [2 ap+0 S4 A32]))
"/tmp/pr120165-1.c":34:18 discrim 1 55 {*movsi_m68k2}
     (nil))
(insn 47 105 106 11 (set (mem:SI (pre_dec:SI (reg/f:SI 15 %sp)) [1  S4 A16])
        (mem:SI (post_inc:SI (reg/f:SI 8 %a0 [53])) [1 MEM[(int *)ap_30]+0 S4
A16])) "/tmp/pr120165-1.c":34:18 discrim 1 55 {*movsi_m68k2}
     (expr_list:REG_INC (reg/f:SI 8 %a0 [53])
        (nil)))
(insn 106 47 48 11 (set (mem/f/c:SI (plus:SI (reg/f:SI 15 %sp)
                (const_int 20 [0x14])) [2 ap+0 S4 A32])
        (reg/f:SI 8 %a0 [53])) "/tmp/pr120165-1.c":34:18 discrim 1 55
{*movsi_m68k2}
     (nil))
(note 48 106 49 11 NOTE_INSN_DELETED)
(call_insn 49 48 50 11 (set (reg:SI 0 %d0)
        (call (mem:QI (symbol_ref:SI ("target") [flags 0x41]  <function_decl
0x7fdffd9e8200 target>) [0 target S1 A8])
            (const_int 4 [0x4]))) "/tmp/pr120165-1.c":34:18 discrim 1 394
{*symbolic_call_value_jsr}
     (expr_list:REG_CALL_DECL (symbol_ref:SI ("target") [flags 0x41] 
<function_decl 0x7fdffd9e8200 target>)
        (nil))
    (expr_list:BLK (use (mem:BLK (reg/f:SI 15 %sp) [0  S4 A8]))
        (nil)) 0)
...

i.e. save ap, restore ap (redundant), fetch & increment ap and push the value,
save incremented ap to wrong stack offset, call.

Reply via email to