[RFC PATCH, i386]: Use %r15 for REAL_PIC_OFFSET_TABLE_REGNUM on x86_64

Uros Bizjak ubizjak@gmail.com
Thu Dec 27 08:08:00 GMT 2012

On Wed, Dec 26, 2012 at 9:16 PM, Andi Kleen <andi@firstfloor.org> wrote:
>> Can you please post a real-world example, where using %r15 would break
>> existing code?
> I used to run into problems like this when porting code to gcc from icc or VC.
> A lot of hyper optimized inline assembler snippets wants to use all registers
> and icc/VC support that. With gcc usually had to add some manual
> push/pops. In older gcc versions usually more than one because reload
> tended to error out otherwise.
> So by try and error used the non fixed registers, but let the compiler know
> about the others. This case would break.
> In 64bit it was less a problem than on 32bit, but could still happen.
> Admittedly medium is somewhat obscure and rarely used (and very slow),
> but someone could be still using it.

The alternative approach is changing cpuid definition in cpuid.h (as
in attached patch) to preserve %rbx, but we can't detect various code
model settings there. Since the change depends on the definition of
__PIC__, we unnecessary preserve %rbx also for -mcmodel=small.
However, code that involves cpuid is rarely performance critical, so
perhaps we can live with this tradeoff.

IMO, this patch can be used on 4.7 branch, too.


More information about the Gcc-patches mailing list