i386.c: Include cselib.h.
authorRichard Sandiford <rdsandiford@googlemail.com>
Tue, 23 Sep 2008 18:29:14 +0000 (18:29 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 23 Sep 2008 18:29:14 +0000 (18:29 +0000)
gcc/
* config/i386/i386.c: Include cselib.h.
(ix86_pic_register_p): New function.
(ix86_delegitimize_address): Use it to check for the PIC register.

From-SVN: r140611

gcc/ChangeLog
gcc/config/i386/i386.c

index ad8ac8d..461044b 100644 (file)
@@ -1,5 +1,11 @@
 2008-09-23  Richard Sandiford  <rdsandiford@googlemail.com>
 
+       * config/i386/i386.c: Include cselib.h.
+       (ix86_pic_register_p): New function.
+       (ix86_delegitimize_address): Use it to check for the PIC register.
+
+2008-09-23  Richard Sandiford  <rdsandiford@googlemail.com>
+
        * doc/tm.texi (FIND_BASE_TERM): Expand documentation.
        * config/i386/i386.c (ix86_find_base_term): Don't check for
        SYMBOL_REF and LABEL_REF.
index 024e433..86be390 100644 (file)
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "df.h"
 #include "tm-constrs.h"
 #include "params.h"
+#include "cselib.h"
 
 static int x86_builtin_vectorization_cost (bool);
 static rtx legitimize_dllimport_symbol (rtx, bool);
@@ -9966,6 +9967,20 @@ i386_output_dwarf_dtprel (FILE *file, int size, rtx x)
    }
 }
 
+/* Return true if X is a representation of the PIC register.  This copes
+   with calls from ix86_find_base_term, where the register might have
+   been replaced by a cselib value.  */
+
+static bool
+ix86_pic_register_p (rtx x)
+{
+  if (GET_CODE (x) == VALUE)
+    return (pic_offset_table_rtx
+           && rtx_equal_for_cselib_p (x, pic_offset_table_rtx));
+  else
+    return REG_P (x) && REGNO (x) == PIC_OFFSET_TABLE_REGNUM;
+}
+
 /* In the name of slightly smaller debug output, and to cater to
    general assembler lossage, recognize PIC+GOTOFF and turn it back
    into a direct symbol reference.
@@ -10004,19 +10019,16 @@ ix86_delegitimize_address (rtx orig_x)
       || GET_CODE (XEXP (x, 1)) != CONST)
     return orig_x;
 
-  if (REG_P (XEXP (x, 0))
-      && REGNO (XEXP (x, 0)) == PIC_OFFSET_TABLE_REGNUM)
+  if (ix86_pic_register_p (XEXP (x, 0)))
     /* %ebx + GOT/GOTOFF */
     ;
   else if (GET_CODE (XEXP (x, 0)) == PLUS)
     {
       /* %ebx + %reg * scale + GOT/GOTOFF */
       reg_addend = XEXP (x, 0);
-      if (REG_P (XEXP (reg_addend, 0))
-         && REGNO (XEXP (reg_addend, 0)) == PIC_OFFSET_TABLE_REGNUM)
+      if (ix86_pic_register_p (XEXP (reg_addend, 0)))
        reg_addend = XEXP (reg_addend, 1);
-      else if (REG_P (XEXP (reg_addend, 1))
-              && REGNO (XEXP (reg_addend, 1)) == PIC_OFFSET_TABLE_REGNUM)
+      else if (ix86_pic_register_p (XEXP (reg_addend, 1)))
        reg_addend = XEXP (reg_addend, 0);
       else
        return orig_x;