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 changes %rbx with %r15 (also following the example in the psABI). This patch has no implications on small code model (that doesn't use REAL_PIC_OFFSET_TABLE_REGNUM anyway), but on medium and large code model fixes usage of cpuid.h (please see PR 55712 [1]) and avoids a pair of xchgs around cmpxchg or cpuid instructions.
Probably, we can also enhance ix86_select_alt_pic_regnum for x86_64, but this is 4.9 material. 2012-12-24 Uros Bizjak <ubiz...@gmail.com> * config/i386/i386.md (R14_REG, R15_REG): New constants. * config/i386/i386.h (REAL_PIC_OFFSET_TABLE_REGNUM): Use R15_REG for 64bit targets. [1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55712 Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Uros.
Index: i386.h =================================================================== --- i386.h (revision 194703) +++ i386.h (working copy) @@ -1173,7 +1173,7 @@ the pic register when possible. The change is visible after the prologue has been emitted. */ -#define REAL_PIC_OFFSET_TABLE_REGNUM BX_REG +#define REAL_PIC_OFFSET_TABLE_REGNUM (TARGET_64BIT ? R15_REG : BX_REG) #define PIC_OFFSET_TABLE_REGNUM \ ((TARGET_64BIT && ix86_cmodel == CM_SMALL_PIC) \ Index: i386.md =================================================================== --- i386.md (revision 194703) +++ i386.md (working copy) @@ -301,6 +301,8 @@ (R11_REG 40) (R12_REG 41) (R13_REG 42) + (R14_REG 43) + (R15_REG 44) (XMM8_REG 45) (XMM9_REG 46) (XMM10_REG 47)