http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57459

--- Comment #6 from wmi at google dot com ---
continue the analysis in the first post, for the smallcase 1.c, the IR after
calling inherit_in_ebb in lra_inheritance for bb12 is:

(insn 289 47 48 12 (set (reg:SI 116 [79])
        (reg:SI 121 [79])) 1.c:16 85 {*movsi_internal}
     (nil))
(insn 48 289 290 12 (set (reg:SI 116 [79])
        (if_then_else:SI (eq (reg:CCNO 17 flags)
                (const_int 0 [0]))
            (reg:SI 122 [83])
            (reg:SI 116 [79]))) 1.c:16 923 {*movsicc_noc}
     (expr_list:REG_DEAD (reg:SI 122 [83])
        (nil)))
(insn 290 48 294 12 (set (reg:SI 120 [79])
        (reg:SI 116 [79])) 1.c:16 85 {*movsi_internal}
     (nil))
(insn 294 290 49 12 (set (reg:SI 79)
        (reg:SI 120 [79])) 1.c:16 85 {*movsi_internal}
     (nil))
......
(insn 292 50 51 12 (set (reg:QI 118)
        (subreg:QI (reg:SI 120 [79]) 0)) 1.c:16 87 {*movqi_internal}
     (nil))
(insn 51 292 52 12 (parallel [
            (set (reg:CC 17 flags)
                (unspec:CC [
                        (subreg:QI (reg:SI 79) 0)
                        (reg:QI 118)
                    ] UNSPEC_ADD_CARRY))
            (set (subreg:QI (reg:SI 79) 0)
                (plus:QI (subreg:QI (reg:SI 79) 0)It is still correct 
                    (reg:QI 118)))
        ]) 1.c:16 259 {addqi3_cc}
     (expr_list:REG_UNUSED (reg:SI 79)
        (nil)))

The IR is still correct after this step. 

However, after update_ebb_live_info (called after inherit_in_ebb), insn 294 is
removed. Then reg 79 cannot get updated value and it doesn't equal to reg 118
anymore. IR is wrong after this step. 
insn 294 is removed in update_ebb_live_info because the reg type of reg 79 is
OP_INOUT but update_ebb_live_info only marks OP_IN type reg as live_regs.

So the fix is:
Index: gcc/lra-constraints.c
===================================================================
--- gcc/lra-constraints.c    (revision 199752)
+++ gcc/lra-constraints.c    (working copy)
@@ -4545,7 +4545,7 @@ update_ebb_live_info (rtx head, rtx tail
       bitmap_clear_bit (&live_regs, reg->regno);
       /* Mark each used value as live.  */
       for (reg = curr_id->regs; reg != NULL; reg = reg->next)
-    if (reg->type == OP_IN
+    if ((reg->type == OP_IN || reg->type == OP_INOUT)
         && bitmap_bit_p (&check_only_regs, reg->regno))
       bitmap_set_bit (&live_regs, reg->regno);
       /* It is quite important to remove dead move insns because it

Bootstrapped and tested on x86_64-linux.

Reply via email to