[RS6000] out-of-line exit register restore funcs

Alan Modra amodra@gmail.com
Wed May 4 04:15:00 GMT 2016


This fixes the regression from gcc-4.5 for -m32 -Os shown by
gcc.target/powerpc/savres.c:s_r31.  Bootstrap and regression tests
on powerpc64le-linux and powerpc64-linux in progress.  OK assuming no
regressions?

	* config/rs6000/rs6000.c (rs6000_savres_strategy): Don't use
	out-of-line gpr restore for one or two regs if that would add
	a save of lr.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 6fa8a0c..ceb3705 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -23435,6 +23435,15 @@ rs6000_savres_strategy (rs6000_stack_t *info,
 	  }
     }
 
+  /* info->lr_save_p isn't yet set if the only reason lr needs to be
+     saved is an out-of-line save or restore.  Set up the value for
+     the next test (excluding out-of-line gprs).  */
+  bool lr_save_p = (info->lr_save_p
+		    || !(strategy & SAVE_INLINE_FPRS)
+		    || !(strategy & SAVE_INLINE_VRS)
+		    || !(strategy & REST_INLINE_FPRS)
+		    || !(strategy & REST_INLINE_VRS));
+
   if (TARGET_MULTIPLE
       && !TARGET_POWERPC64
       && !(TARGET_SPE_ABI && info->spe_64bit_regs_used)
@@ -23444,15 +23453,6 @@ rs6000_savres_strategy (rs6000_stack_t *info,
 	 since the store-multiple instruction will always be smaller.  */
       strategy |= SAVE_INLINE_GPRS | SAVE_MULTIPLE;
 
-      /* info->lr_save_p isn't yet set if the only reason lr needs to be
-	 saved is an out-of-line save or restore.  Set up the value for
-	 the next test (excluding out-of-line gprs).  */
-      bool lr_save_p = (info->lr_save_p
-			|| !(strategy & SAVE_INLINE_FPRS)
-			|| !(strategy & SAVE_INLINE_VRS)
-			|| !(strategy & REST_INLINE_FPRS)
-			|| !(strategy & REST_INLINE_VRS));
-
       /* The situation is more complicated with load multiple.  We'd
 	 prefer to use the out-of-line routines for restores, since the
 	 "exit" out-of-line routines can handle the restore of LR and the
@@ -23465,6 +23465,12 @@ rs6000_savres_strategy (rs6000_stack_t *info,
 	strategy |= REST_INLINE_GPRS | REST_MULTIPLE;
     }
 
+  /* Using the "exit" out-of-line routine does not improve code size
+     if using it would require lr to be saved and if only saving one
+     or two gprs.  */
+  else if (!lr_save_p && info->first_gp_reg_save > 29)
+    strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
+
   /* We can only use load multiple or the out-of-line routines to
      restore gprs if we've saved all the registers from
      first_gp_reg_save.  Otherwise, we risk loading garbage.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Gcc-patches mailing list