summaryrefslogtreecommitdiff
path: root/gcc/local-alloc.c
diff options
context:
space:
mode:
authorJ"orn Rennecke <amylaar@cygnus.co.uk>1998-12-01 10:00:11 +0000
committerJoern Rennecke <amylaar@gcc.gnu.org>1998-12-01 10:00:11 +0000
commit2b49ee39817f8849f931611cdc13a8d18cd209c7 (patch)
treeb9995987f19d6ca65c15b71f6f69120fde1b5af5 /gcc/local-alloc.c
parentbbe348cd18f81dd9469c81ba6f498e01ca9c5a37 (diff)
downloadgcc-2b49ee39817f8849f931611cdc13a8d18cd209c7.tar.gz
local-alloc.c (function_invariant_p): New function.
* local-alloc.c (function_invariant_p): New function. (update_equiv_regs): Use function_invariant_p instead of CONSTANT_P to decide if an equivalence should be recorded. * reload1.c (num_eliminable_invariants): New static variable. (reload): Set it. Use function_invariant_p instead of CONSTANT_P to decide if an equivalence should be recorded. Unshare PLUS. (calculate_needs_all_insns): Skip insns that only set an equivalence. Take num_eliminable_invariants into account when deciding if register elimination should be done. (reload_as_needed): Take num_eliminable_invariants into account when deciding if register elimination should be done. (eliminate_regs): Handle non-constant reg_equiv_constant. * rtl.h (function_invariant_p): Declare. From-SVN: r24026
Diffstat (limited to 'gcc/local-alloc.c')
-rw-r--r--gcc/local-alloc.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/local-alloc.c b/gcc/local-alloc.c
index e8110acae0e..f112713b284 100644
--- a/gcc/local-alloc.c
+++ b/gcc/local-alloc.c
@@ -630,6 +630,22 @@ memref_used_between_p (memref, start, end)
return 0;
}
+/* Return nonzero if the rtx X is invariant over the current function. */
+int
+function_invariant_p (x)
+ rtx x;
+{
+ if (CONSTANT_P (x))
+ return 1;
+ if (x == frame_pointer_rtx || x == arg_pointer_rtx)
+ return 1;
+ if (GET_CODE (x) == PLUS
+ && (XEXP (x, 0) == frame_pointer_rtx || XEXP (x, 0) == arg_pointer_rtx)
+ && CONSTANT_P (XEXP (x, 1)))
+ return 1;
+ return 0;
+}
+
/* Find registers that are equivalent to a single value throughout the
compilation (either because they can be referenced in memory or are set once
from a single constant). Lower their priority for a register.
@@ -798,7 +814,7 @@ update_equiv_regs ()
if (REG_N_SETS (regno) != 1
&& (! note
- || ! CONSTANT_P (XEXP (note, 0))
+ || ! function_invariant_p (XEXP (note, 0))
|| (reg_equiv_replacement[regno]
&& ! rtx_equal_p (XEXP (note, 0),
reg_equiv_replacement[regno]))))
@@ -812,7 +828,7 @@ update_equiv_regs ()
/* If this register is known to be equal to a constant, record that
it is always equivalent to the constant. */
- if (note && CONSTANT_P (XEXP (note, 0)))
+ if (note && function_invariant_p (XEXP (note, 0)))
PUT_MODE (note, (enum machine_mode) REG_EQUIV);
/* If this insn introduces a "constant" register, decrease the priority