On 06/23/2010 06:03 AM, Alan Modra wrote:
> On Tue, Jun 08, 2010 at 10:27:03PM +0930, Alan Modra wrote:
>> PowerPC64 gcc support for a larger TOC via -mcmodel option.
> [snip]
> 
> I'm having second thoughts about the optimization I added to PowerPC64
> gcc with the patch hunk below.  Its effect is to use a more efficient
> TOC/GOT pointer relative address calculation on references known to be
> local, rather than loading an address out of the TOC/GOT.  ie.
> 
>   addis rx,2,s...@toc@ha
>   addi ry,rx,s...@toc@l
> 
> instead of
> 
>   addis rx,2,s...@got@ha
>   ld ry,s...@got@l(rx)
> 
> This saves a word in the TOC/GOT and is a little faster too.  However,
> there is a problem:  If people build PowerPC64 shared libraries
> without -fpic/-fPIC then gcc will emit code that requires text relocs
> to properly support ELF shared library semantics, and I don't intend
> to change ld and ld.so to do that.

Given that the x86_64 ld issues hard errors when people forget -fpic
building shared libraries, I don't think this is too much of a problem.

That said...

> It may be better to not do this optimization in gcc at all, especially
> since we can do the same transformation in ld.  This would mean
> PowerPC64 gcc would lose -mcmodel=medium, retaining -mcmodel=small and
> -mcmodel=large.  If there are no dissenting opinions I'll prepare a
> gcc patch to do that.

Simplifying the code models that the user sees is a good thing.
So long as the assembly is still available for those that want
to explicitly schedule the add instead of the ld insn, and it
doesn't sound like you're planning to change that at all.


r~

Reply via email to