[committed] Clean up ADDRESS handling in alias.c, take 2
Richard Sandiford
rdsandiford@googlemail.com
Sat Apr 21 18:56:00 GMT 2012
To compound my woe on this one: it turns out that there's also a use
of ADDRESS in store-motion.c. Obviously a very poor grep session
on my part.
dse.c and store-motion.c are checking for the same thing, and they are
also the only two external users of find_base_term. It seemed better
to define a higher-level function for them to use instead.
I moved the UNIQUE_BASE_* constants from alias.h to alias.c to
emphasise that ADDRESS really should be local to alias.c.
Also, after all that fuss about using HOST_WIDE_INT as the ADDRESS
argument, I realised that the counter we use has always been a plain "int".
We might as well use "i" instead, which will save room on 32-bit hosts.
Bootstrapped & regression-tested on x86_64-linux-gnu. The "w"->"i"
change seemed obvious, and the rest is rtl optimisation stuff, so:
applied to clear the PR.
Richard
gcc/
PR bootstrap/53021
* rtl.def (ADDRESS): Use "i" rather than "w".
* rtl.h (find_base_term): Delete.
(may_be_sp_based_p): Declare.
* rtl.c (rtx_code_size): Remove ADDRESS special case.
* alias.h (UNIQUE_BASE_VALUE_SP, UNIQUE_BASE_VALUE_ARGP)
(UNIQUE_BASE_VALUE_FP, UNIQUE_BASE_VALUE_HFP): Move to...
* alias.c: ...here.
(find_base_term): Make static.
(may_be_sp_based_p): New function.
* dse.c (record_store): Use it.
* store-motion.c (store_killed_in_insn): Likewise.
Index: gcc/rtl.def
===================================================================
--- gcc/rtl.def 2012-04-21 13:46:34.035549209 +0100
+++ gcc/rtl.def 2012-04-21 18:50:46.271865336 +0100
@@ -110,7 +110,7 @@ DEF_RTL_EXPR(INSN_LIST, "insn_list", "ue
DEF_RTL_EXPR(SEQUENCE, "sequence", "E", RTX_EXTRA)
/* Represents a non-global base address. This is only used in alias.c. */
-DEF_RTL_EXPR(ADDRESS, "address", "w", RTX_EXTRA)
+DEF_RTL_EXPR(ADDRESS, "address", "i", RTX_EXTRA)
/* ----------------------------------------------------------------------
Expression types used for things in the instruction chain.
Index: gcc/rtl.h
===================================================================
--- gcc/rtl.h 2012-04-21 13:46:34.064549203 +0100
+++ gcc/rtl.h 2012-04-21 18:50:47.765865292 +0100
@@ -2597,7 +2597,7 @@ extern void init_alias_analysis (void);
extern void end_alias_analysis (void);
extern void vt_equate_reg_base_value (const_rtx, const_rtx);
extern bool memory_modified_in_insn_p (const_rtx, const_rtx);
-extern rtx find_base_term (rtx);
+extern bool may_be_sp_based_p (rtx);
extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int);
extern rtx get_reg_known_value (unsigned int);
extern bool get_reg_known_equiv_p (unsigned int);
Index: gcc/rtl.c
===================================================================
--- gcc/rtl.c 2012-04-21 13:46:34.063549202 +0100
+++ gcc/rtl.c 2012-04-21 18:50:46.130865340 +0100
@@ -111,7 +111,7 @@ #define DEF_RTL_EXPR(ENUM, NAME, FORMAT,
const unsigned char rtx_code_size[NUM_RTX_CODE] = {
#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \
(((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE \
- || (ENUM) == CONST_FIXED || (ENUM) == ADDRESS) \
+ || (ENUM) == CONST_FIXED) \
? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \
: RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (rtunion)),
Index: gcc/alias.h
===================================================================
--- gcc/alias.h 2012-04-21 13:46:34.044549199 +0100
+++ gcc/alias.h 2012-04-21 18:50:46.945865316 +0100
@@ -51,11 +51,4 @@ extern int nonoverlapping_memrefs_p (con
memory barriers, including an address of SCRATCH. */
#define ALIAS_SET_MEMORY_BARRIER ((alias_set_type) -1)
-/* Values of XWINT (address, 0) of Pmode ADDRESS rtxes for special
- registers. */
-#define UNIQUE_BASE_VALUE_SP -1
-#define UNIQUE_BASE_VALUE_ARGP -2
-#define UNIQUE_BASE_VALUE_FP -3
-#define UNIQUE_BASE_VALUE_HFP -4
-
#endif /* GCC_ALIAS_H */
Index: gcc/alias.c
===================================================================
--- gcc/alias.c 2012-04-21 13:46:34.064549203 +0100
+++ gcc/alias.c 2012-04-21 19:05:05.222840362 +0100
@@ -228,6 +228,13 @@ static GTY(()) rtx arg_base_value;
array. */
static GTY((deletable)) VEC(rtx,gc) *old_reg_base_value;
+/* Values of XINT (address, 0) of Pmode ADDRESS rtxes for special
+ registers. */
+#define UNIQUE_BASE_VALUE_SP -1
+#define UNIQUE_BASE_VALUE_ARGP -2
+#define UNIQUE_BASE_VALUE_FP -3
+#define UNIQUE_BASE_VALUE_HFP -4
+
#define static_reg_base_value \
(this_target_rtl->x_static_reg_base_value)
@@ -1584,7 +1591,7 @@ rtx_equal_for_memref_p (const_rtx x, con
return 1;
}
-rtx
+static rtx
find_base_term (rtx x)
{
cselib_val *val;
@@ -1740,6 +1747,16 @@ find_base_term (rtx x)
}
}
+/* Return true if accesses to address X may alias accesses based
+ on the stack pointer. */
+
+bool
+may_be_sp_based_p (rtx x)
+{
+ rtx base = find_base_term (x);
+ return !base || base == static_reg_base_value[STACK_POINTER_REGNUM];
+}
+
/* Return 0 if the addresses X and Y are known to point to different
objects, 1 if they might be pointers to the same object. */
Index: gcc/dse.c
===================================================================
--- gcc/dse.c 2012-04-21 13:46:34.044549199 +0100
+++ gcc/dse.c 2012-04-21 18:50:47.305865305 +0100
@@ -1499,11 +1499,7 @@ record_store (rtx body, bb_info_t bb_inf
}
else
{
- rtx base_term = find_base_term (XEXP (mem, 0));
- if (!base_term
- || (GET_CODE (base_term) == ADDRESS
- && GET_MODE (base_term) == Pmode
- && XWINT (base_term, 0) == UNIQUE_BASE_VALUE_SP))
+ if (may_be_sp_based_p (XEXP (mem, 0)))
insn_info->stack_pointer_based = true;
insn_info->contains_cselib_groups = true;
Index: gcc/store-motion.c
===================================================================
--- gcc/store-motion.c 2012-04-21 13:46:34.052549205 +0100
+++ gcc/store-motion.c 2012-04-21 18:50:48.146865281 +0100
@@ -395,7 +395,7 @@ store_killed_in_pat (const_rtx x, const_
static bool
store_killed_in_insn (const_rtx x, const_rtx x_regs, const_rtx insn, int after)
{
- const_rtx reg, base, note, pat;
+ const_rtx reg, note, pat;
if (! NONDEBUG_INSN_P (insn))
return false;
@@ -410,14 +410,8 @@ store_killed_in_insn (const_rtx x, const
/* But even a const call reads its parameters. Check whether the
base of some of registers used in mem is stack pointer. */
for (reg = x_regs; reg; reg = XEXP (reg, 1))
- {
- base = find_base_term (XEXP (reg, 0));
- if (!base
- || (GET_CODE (base) == ADDRESS
- && GET_MODE (base) == Pmode
- && XEXP (base, 0) == stack_pointer_rtx))
- return true;
- }
+ if (may_be_sp_based_p (XEXP (reg, 0)))
+ return true;
return false;
}
More information about the Gcc-patches
mailing list