Hi! For %rip addressing, we only can use disp32 and thus can add constants to the symbol/label, but not a register etc., as there is no instruction supporting (plus (symbol_ref) (reg)) for PIC.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-03-27 Jakub Jelinek <ja...@redhat.com> PR target/65593 * config/i386/i386.c (legitimize_pic_address): If base is SYMBOL_REF or LABEL_REF using %rip addressing, force it to reg to avoid PLUS of SYMBOL_REF/LABEL_REF and register. * gcc.c-torture/compile/pr65593.c: New test. --- gcc/config/i386/i386.c.jj 2015-03-23 16:31:27.000000000 +0100 +++ gcc/config/i386/i386.c 2015-03-27 14:19:54.646117550 +0100 @@ -13881,6 +13881,12 @@ legitimize_pic_address (rtx orig, rtx re } else { + /* For %rip addressing, we have to use just disp32, not + base nor index. */ + if (TARGET_64BIT + && (GET_CODE (base) == SYMBOL_REF + || GET_CODE (base) == LABEL_REF)) + base = force_reg (mode, base); if (GET_CODE (new_rtx) == PLUS && CONSTANT_P (XEXP (new_rtx, 1))) { --- gcc/testsuite/gcc.c-torture/compile/pr65593.c.jj 2015-03-27 14:40:55.973767411 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr65593.c 2015-03-27 14:42:19.697417036 +0100 @@ -0,0 +1,4 @@ +/* PR target/65593 */ +/* { dg-additional-options "-fpie" { target pie } } */ + +#include "pr20928.c" Jakub