This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PowerPC64, optimization too aggressive?

On Tue, Jun 08, 2010 at 10:27:03PM +0930, Alan Modra wrote:
> PowerPC64 gcc support for a larger TOC via -mcmodel option.

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,sym@toc@ha
  addi ry,rx,sym@toc@l

instead of

  addis rx,2,sym@got@ha
  ld ry,sym@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 to do that.

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.

> +	      && GET_CODE (operands[1]) == SYMBOL_REF
> +	      && !CONSTANT_POOL_ADDRESS_P (operands[1])
> +	      && SYMBOL_REF_LOCAL_P (operands[1])
> +	      && offsettable_ok_by_alignment (SYMBOL_REF_DECL (operands[1]))))

Alan Modra
Australia Development Lab, IBM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]