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

--- Comment #32 from Peter Bergner <bergner at gcc dot gnu.org> ---
(In reply to Peter Bergner from comment #26)
> (In reply to Vladimir Makarov from comment #25)
> > (In reply to Peter Bergner from comment #24)
> >> I don't know why r0 isn't in profitable_regs for pseudo 116.
> >  
> > Profitable regs there contain also conflict regs.  R0 is conflicting with
> > p106. If R0 usage (in call insn) were in the same BB, your new conflict
> > calculation found that there is no actual conflict.  But IRA uses
> > df-infrastructure which tells IRA that R0 lives at the BB end where p106
> > occurs.
> 
> I'm sorry, but I don't see where p116 conflicts with r0.  Can you show me
> where/how?  Looking at my IRA dump, I see:

Ok, so there is a bug in print_allocno_conflicts() that causes us to skip
printing the hard reg conflicts if the allocno doesn't have any conflicts with
other allocnos.  I submitted a patch to fix that.  With the fix, I know see the
following conflict info for p116:

;; a5(r116,l0) conflicts:
;;     total conflict hard regs: 0
;;     conflict hard regs:

So this explains why p116 isn't assigned r0.  That doesn't explain why p116
conflicts with r0 though, because looking at the rtl brlow, it shouldn't:

<r0 is live here>
(insn 50 3 7 2 (set (reg:SI 116)
        (reg:SI 0 r0 [ aD.4197 ])) "bug.i":7:1 181 {*arm_movsi_insn}
     (nil))
(insn 7 50 8 2 (parallel [
            (set (reg:CC 100 cc)
                (compare:CC (reg:SI 116)
                    (const_int 0 [0])))
            (set (reg/v:SI 112 [ aD.4197 ])
                (reg:SI 116))
        ]) "bug.i":10:6 188 {*movsi_compare0}
     (expr_list:REG_DEAD (reg:SI 116)
        (nil)))
<r0 is live here>

So yes, r0 is live at the definition of p116, we know they have the same value.
 My ira-conflicts.c changes adding non_conflicting_reg_copy_p() should have
handled that, but it isn't.  Now non_conflicting_reg_copy_p() does correctly
notice that insn 50 is a simple copy that we can ignore for conflict purposes,
but somehow, a conflict is still being added.

I tracked the problem down to ira-conflicts.c:make_object_dead() not handling
ignore_reg_for_conflicts correctly.  The bug is that we correctly remove the
ignored reg (r0) from OBJECT_CONFLICT_HARD_REGS, but we miss removing it from
OBJECT_TOTAL_CONFLICT_HARD_REGS too.  I'm working on a patch.

Reply via email to