mips.c (machine_function): Add initialized_mips16_gp_pseudo_p.
authorRichard Sandiford <richard@codesourcery.com>
Wed, 25 Jul 2007 18:12:15 +0000 (18:12 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 25 Jul 2007 18:12:15 +0000 (18:12 +0000)
gcc/
* config/mips/mips.c (machine_function): Add
initialized_mips16_gp_pseudo_p.
(mips16_gp_pseudo_reg): Do not emit the initialization of
mips16_gp_pseudo_rtx when being called from the gimple cost-
calculation routines; emit it on the first use outside those
routines.

From-SVN: r126919

gcc/ChangeLog
gcc/config/mips/mips.c

index aee6233..20bcc69 100644 (file)
@@ -1,3 +1,12 @@
+2007-07-25  Richard Sandiford  <richard@codesourcery.com>
+
+       * config/mips/mips.c (machine_function): Add
+       initialized_mips16_gp_pseudo_p.
+       (mips16_gp_pseudo_reg): Do not emit the initialization of
+       mips16_gp_pseudo_rtx when being called from the gimple cost-
+       calculation routines; emit it on the first use outside those
+       routines.
+
 2007-07-25  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * coretypes.h (const_bitmap, const_rtx, const_rtvec, const_tree):
index f42fe77..e9e79ee 100644 (file)
@@ -477,6 +477,10 @@ struct machine_function GTY(()) {
 
   /* True if the function is known to have an instruction that needs $gp.  */
   bool has_gp_insn_p;
+
+  /* True if we have emitted an instruction to initialize
+     mips16_gp_pseudo_rtx.  */
+  bool initialized_mips16_gp_pseudo_p;
 };
 
 /* Information about a single argument.  */
@@ -8774,11 +8778,15 @@ static rtx
 mips16_gp_pseudo_reg (void)
 {
   if (cfun->machine->mips16_gp_pseudo_rtx == NULL_RTX)
+    cfun->machine->mips16_gp_pseudo_rtx = gen_reg_rtx (Pmode);
+
+  /* Don't initialize the pseudo register if we are being called from
+     the tree optimizers' cost-calculation routines.  */
+  if (!cfun->machine->initialized_mips16_gp_pseudo_p
+      && current_ir_type () != IR_GIMPLE)
     {
       rtx insn, scan;
 
-      cfun->machine->mips16_gp_pseudo_rtx = gen_reg_rtx (Pmode);
-
       /* We want to initialize this to a value which gcc will believe
          is constant.  */
       insn = gen_load_const_gp (cfun->machine->mips16_gp_pseudo_rtx);
@@ -8794,6 +8802,8 @@ mips16_gp_pseudo_reg (void)
        scan = get_insns ();
       insn = emit_insn_after (insn, scan);
       pop_topmost_sequence ();
+
+      cfun->machine->initialized_mips16_gp_pseudo_p = true;
     }
 
   return cfun->machine->mips16_gp_pseudo_rtx;