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

--- Comment #15 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
The insn in question is
 (insn 3598 3597 6907 395 (parallel [
            (set (reg:CC 100 cc)
                (compare:CC (reg:SI 307 [ ls$2 ])
                    (const_int 0 [0])))
            (set (reg:SI 192 [ D.62648 ])
                (reg:SI 307 [ ls$2 ]))
        ]) ../../gcc-4.9.2/gcc/haifa-sched.c:6368 204 {*movsi_compare0}
     (expr_list:REG_DEAD (reg:SI 307 [ ls$2 ])
        (expr_list:REG_UNUSED (reg:CC 100 cc)
            (nil))))

The insn definition is

(define_insn "*movsi_compare0"
  [(set (reg:CC CC_REGNUM)
        (compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
                    (const_int 0)))
   (set (match_operand:SI 0 "s_register_operand" "=r,r")
        (match_dup 1))]

LRA choosing the first alternative where the 0 and 1 operand should be the same
and generates

(insn 3598 7755 7756 395 (parallel [
            (set (reg:CC 100 cc)
                (compare:CC (reg:SI 3686 [orig:192 D.62648 ] [192])
                    (const_int 0 [0])))
            (set (reg:SI 3686 [orig:192 D.62648 ] [192])
                (reg:SI 3686 [orig:192 D.62648 ] [192]))
        ]) ../../gcc-4.9.2/gcc/haifa-sched.c:6368 204 {*movsi_compare0}
     (expr_list:REG_DEAD (reg:SI 307 [ ls$2 ])
        (expr_list:REG_UNUSED (reg:CC 100 cc)
            (nil))))

The generated ins is ok.  The code in lra_lives.c::process_bb_lives is

          if (dst_regno >= lra_constraint_new_regno_start
              && src_regno >= lra_constraint_new_regno_start)
            lra_create_copy (dst_regno, src_regno, freq);

The code was written to process reload insns only but insn 3598 looks like
reload because it is a single_set insn (reg 100 is unused).

lra_create_copy has an assertion that dst_regno and src_regno are different
which fails.

The fix should be trivial.  I'll commit it soon.

Reply via email to