diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index faa92264ee7cc20c84dcf974fe56062e64036de6..9b3fc6ef69ada769be6ba8e6e77225833cf268c8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-17  Richard Sandiford  <rdsandiford@googlemail.com>
+
+	* config/mips/mips.c (mips_save_reg_p): Don't short-circuit rest
+	of function when handling GLOBAL_POINTER_REGNUM.
+
 2008-08-16  Eric Botcazou  <ebotcazou@adacore.com>
 
 	PR ada/20548
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 48daec4175d232061be3bf00e7a98f33367b8c43..51af59b2f1c3fc4d3b14b8fb5644f7ab6ba07d90 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -8322,10 +8322,12 @@ mips_global_pointer (void)
 static bool
 mips_save_reg_p (unsigned int regno)
 {
-  /* We only need to save $gp if TARGET_CALL_SAVED_GP and only then
-     if we have not chosen a call-clobbered substitute.  */
-  if (regno == GLOBAL_POINTER_REGNUM)
-    return TARGET_CALL_SAVED_GP && cfun->machine->global_pointer == regno;
+  /* We need to save $gp if TARGET_CALL_SAVED_GP and if we have not
+     chosen a call-clobbered substitute.  */
+  if (TARGET_CALL_SAVED_GP
+      && regno == GLOBAL_POINTER_REGNUM
+      && cfun->machine->global_pointer == regno)
+    return true;
 
   /* Check call-saved registers.  */
   if ((crtl->saves_all_registers || df_regs_ever_live_p (regno))