This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [mips] fix $gp restore bug
Maciej W. Rozycki writes:
> On Mon, 2 Mar 2009, Adam Nemet wrote:
> > > Let's face it -- it's not the instruction list which is inadequate. It
> > > is the decision to make $gp call-clobbered for o32 which was suboptimal.
> > > There was a reason it got fixed with the advent of the new ABIs (along
> > > with a number of other issues).
> >
> > AIUI, the problem exists with the new ABIs as well. You either ensure that
> > the GOT pointer is live at each branch pessimizing the code or you need a
> > different way of fetching the destination address into a register.
>
> Well, $gp is call-saved with the new ABIs and given the other eight
> static registers there is little point in clobbering $gp once it has been
> set up in the prologue. Too much hassle for too little gain IMO.
Yes but what if it isn't set up in the prologue. Do you always force the
allocation of the GOT pointer even if it won't be used most likely just
because there is a branch? If not then you need a way of loading a
destination address into $1, which as it seems requires another temporary with
the new ABIs lacking (D)ADDIUPC.
Also, Richard's point is, that once you work out this sequence, you could use
it even if there is a GOT register instead of extending the lifetime of the
GOT register to all branches. But I agree, this latter point might be
something worthwhile to measure.
Adam