This patch came about because I noticed a comment about "the second
condition" in rs6000_emit_epilogue no longer matched the code.  I was
going to fix the comment, then noticed the code could be simplified.

In rs6000_emit_epilogue, lr_save_offset is a small positive value (4,8
or 16), or zero when !lr_save_p, and total_size a HOST_WIDE_INT.  In
rs6000_legitimate_offset_address_p, "offset" is an unsigned
HOST_WIDE_INT, "extra" a value between 0 and 12.

Unless my numerical analysis has totally deserted me, the new code
here is exactly equivalent to the old.  Bootstrapped and regression
tested powerpc-linux.  Committing as obvious.

        * config/rs6000/rs6000.c (rs6000_emit_epilogue): Simplify
        use_backchain_to_restore_sp initialisation.
        (rs6000_legitimate_offset_address_p): Simplify offset test.

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  (revision 177267)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -5391,9 +5391,9 @@ rs6000_legitimate_offset_address_p (enum
       break;
     }
 
   offset += 0x8000;
-  return (offset < 0x10000) && (offset + extra < 0x10000);
+  return offset < 0x10000 - extra;
 }
 
 bool
 legitimate_indexed_address_p (rtx x, int strict)
@@ -20711,12 +20711,9 @@ rs6000_emit_epilogue (int sibcall)
      is more efficient than an addis, addi pair.  The second condition
      here will not trigger at the moment;  We don't actually need a
      frame pointer for alloca, but the generic parts of the compiler
      give us one anyway.  */
-  use_backchain_to_restore_sp = (info->total_size > 32767
-                                || info->total_size
-                                    + (info->lr_save_p ? info->lr_save_offset 
: 0)
-                                      > 32767
+  use_backchain_to_restore_sp = (info->total_size > 32767 - 
info->lr_save_offset
                                 || (cfun->calls_alloca
                                     && !frame_pointer_needed));
   restore_lr = (info->lr_save_p
                && (restoring_FPRs_inline

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to