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

--- Comment #21 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Vladimir Makarov from comment #20)
> (In reply to Wilco from comment #19)
> > (In reply to Peter Bergner from comment #18)
> > > (In reply to Segher Boessenkool from comment #15)
> > > >       Popping a5(r116,l0)  -- assign reg 3
> > > >       Popping a3(r112,l0)  -- assign reg 4
> > > >       Popping a2(r114,l0)  -- assign reg 3
> > > >       Popping a0(r111,l0)  -- assign reg 0
> > > >       Popping a4(r117,l0)  -- assign reg 0
> > > >       Popping a1(r113,l0)  -- assign reg 2
> > > > Assigning 4 to a5r116
> > > > Disposition:
> > > >     0:r111 l0     0    3:r112 l0     4    1:r113 l0     2    2:r114 l0  
> > > >    3
> > > >     5:r116 l0     4    4:r117 l0     0
> > > > 
> > > > 
> > > > r116 does not conflict with *any* other pseudo.  It is alive in the 
> > > > first
> > > > two insns of the function, which are
> > > 
> > > So we initially assign r3 to r116 presumably because it has the same cost 
> > > as
> > > the other gprs and it occurs first in REG_ALLOC_ORDER.  Then
> > > improve_allocation() decides that r4 is a better hard reg and switches the
> > > assignment to that.  I'm not sure why it wouldn't choose r0 there instead.
> > 
> > I would expect that r116 has a strong preference for r0 given the r116 = mov
> > r0 and thus allocating r116 to r0 should have the lowest cost by a large
> > margin.
> 
> p116 conflicts with hr0.  Therefore it can not get hr0.  p112 is connected
> with p116.  p112 got hr4 and p116 got 3.  Assigning 4 to 116 is profitable. 
> Therefore assignment of p116 is changed to 4.
> 
> The question is why p116 conflicts with hr0.  Before RA we have

That's a bug since register copies should not create a conflict. It's one of
the most basic optimization of register allocator.

And there is also the question why we do move r0 into a virtual register but
not assign the virtual register to an argument register.

Reply via email to