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

2013-01-04 Thread Leif Ekblad
em? Might that be because it will not use rbx, but instead another register? OTOH, the code seems to work and rbx is not assigned to PIC at the point of the call, but to the defined parameter. Regards, Leif Ekblad - Original Message - From: "Jakub Jelinek" To: "Le

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

2013-01-04 Thread Jakub Jelinek
On Fri, Jan 04, 2013 at 10:39:05PM +0100, Leif Ekblad wrote: > I just tried the patch, but it seems to produce some problems for > me. The other patch which used a 64-bit specific register (r15) > instead of rbx was easier to adapt to. The problem for me is that > syscalls might clobber higher-half

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

2013-01-04 Thread Leif Ekblad
Original Message ----- From: "Uros Bizjak" To: "Richard Henderson" Cc: "Andi Kleen" ; "Mike Frysinger" ; ; "Leif Ekblad" ; "Jakub Jelinek" ; ; "H.J. Lu" Sent: Sunday, December 30, 2012 8:08 PM Subject: Re: [RFC PATCH, i38

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

2012-12-30 Thread Uros Bizjak
On Fri, Dec 28, 2012 at 9:27 PM, Richard Henderson wrote: > On 12/27/2012 12:08 AM, Uros Bizjak wrote: >> 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

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

2012-12-28 Thread Richard Henderson
On 12/27/2012 12:08 AM, Uros Bizjak wrote: > 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 als

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

2012-12-27 Thread Uros Bizjak
On Thu, Dec 27, 2012 at 10:10 AM, Florian Weimer wrote: > * Uros Bizjak: > >> +#elif defined(__x86_64__) >> +#define __cpuid(level, a, b, c, d) \ >> + __asm__ ("xchg{q}\t{%%}rbx, %q1\n\t" \ >> +"cpuid\n\t" \ >> +

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

2012-12-27 Thread Florian Weimer
* Uros Bizjak: > +#elif defined(__x86_64__) > +#define __cpuid(level, a, b, c, d) \ > + __asm__ ("xchg{q}\t{%%}rbx, %q1\n\t" \ > +"cpuid\n\t" \ > +"xchg{q}\t{%%}rbx, %q1\n\t" \ > +: "

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

2012-12-27 Thread Uros Bizjak
On Thu, Dec 27, 2012 at 9:08 AM, Uros Bizjak wrote: > On Wed, Dec 26, 2012 at 9:16 PM, Andi Kleen 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

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

2012-12-27 Thread Uros Bizjak
On Wed, Dec 26, 2012 at 9:16 PM, Andi Kleen 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 re

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

2012-12-26 Thread Andi Kleen
> 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 ad

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

2012-12-26 Thread Uros Bizjak
On Tue, Dec 25, 2012 at 8:27 PM, Mike Frysinger wrote: >> >> In the case of cpuid, the code is hardly performance sensitive, and >> >> probably runs only at startup. An alternative solution for the broken >> >> code here is to move the result from rbx to another register, and to >> >> save/restor

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

2012-12-25 Thread Mike Frysinger
On Tuesday 25 December 2012 14:12:09 Uros Bizjak wrote: > On Tue, Dec 25, 2012 at 6:54 AM, Mike Frysinger wrote: > > On Monday 24 December 2012 17:26:47 Leif Ekblad wrote: > >> In the case of cpuid, the code is hardly performance sensitive, and > >> probably runs only at startup. An alternative so

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

2012-12-25 Thread Uros Bizjak
On Tue, Dec 25, 2012 at 6:54 AM, Mike Frysinger wrote: > On Monday 24 December 2012 17:26:47 Leif Ekblad wrote: >> In the case of cpuid, the code is hardly performance sensitive, and >> probably runs only at startup. An alternative solution for the broken code >> here is to move the result from rb

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

2012-12-24 Thread Mike Frysinger
On Monday 24 December 2012 17:26:47 Leif Ekblad wrote: > In the case of cpuid, the code is hardly performance sensitive, and > probably runs only at startup. An alternative solution for the broken code > here is to move the result from rbx to another register, and to > save/restore rbx. Currently,

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

2012-12-24 Thread Leif Ekblad
this problem. Leif Ekblad - Original Message - From: "Andi Kleen" To: "Uros Bizjak" Cc: ; "Richard Henderson" ; "Jakub Jelinek" ; ; "H.J. Lu" Sent: Monday, December 24, 2012 10:32 PM Subject: Re: [RFC PATCH, i386]: Use %r15 for REAL_

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

2012-12-24 Thread Andi Kleen
Uros Bizjak writes: > Hello! > > Currently, we use %rbx as REAL_PIC_OFFSET_TABLE_REGNUM on x86_64. > Since this register gets marked as fixed reg in > ix86_conditional_register_usage, we get into troubles with insns that > use %rbx (cmpxchg, cpuid). According to x86_64 psABI, we are free to > use

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

2012-12-24 Thread Uros Bizjak
Hello! Currently, we use %rbx as REAL_PIC_OFFSET_TABLE_REGNUM on x86_64. Since this register gets marked as fixed reg in ix86_conditional_register_usage, we get into troubles with insns that use %rbx (cmpxchg, cpuid). According to x86_64 psABI, we are free to use any register, so attached patch ch