aboutsummaryrefslogtreecommitdiff
path: root/gcc/alias.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>1999-12-18 21:33:23 +0000
committerRichard Kenner <kenner@gcc.gnu.org>1999-12-18 16:33:23 -0500
commitd4b60170fd601e84cdafca12ea3365488ee93635 (patch)
treeb29d6812261abeb25b182a176f35382f12cb98bd /gcc/alias.c
parent3f0aabf20a84ccd50d38dca8f252f887558d31ff (diff)
downloadgcc-d4b60170fd601e84cdafca12ea3365488ee93635.zip
gcc-d4b60170fd601e84cdafca12ea3365488ee93635.tar.gz
gcc-d4b60170fd601e84cdafca12ea3365488ee93635.tar.bz2
alias.c: Minor reformatting.
* alias.c: Minor reformatting. * flow.c: Likewise. * regs.h: Likewise. * stor-layout.c: Likewise. * fold-const.c: Likewise. (OVERFLOW_SUM_SIGN): Renamed from overflow_sum_sign. (struct cb_args, const_binop_1, const_binop): Pass type of arg, not arg itself. (size_int_wide): Cache nodes even if garbage collecting. (twoval_comparison_p): Reenable SAVE_EXPR case if operand of SAVE_EXPR has no side effects. * cse.c: Move a comment. * tree.c: Minor reformatting. (int_size_in_bytes): Return -1 if constant overflows. * reload.c (combine_reloads): Do nothing if no output reload From-SVN: r31017
Diffstat (limited to 'gcc/alias.c')
-rw-r--r--gcc/alias.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/gcc/alias.c b/gcc/alias.c
index ebb1e7c..e788ed3 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -53,7 +53,7 @@ Boston, MA 02111-1307, USA. */
int double
(The arrows are directed and point downwards.) If, when comparing
- two alias sets, we can hold one set fixed, and trace the other set
+ two alias sets, we can hold one set fixed, trace the other set
downwards, and at some point find the first set, the two MEMs can
alias one another. In this situation we say the alias set for
`struct S' is the `superset' and that those for `int' and `double'
@@ -63,7 +63,8 @@ Boston, MA 02111-1307, USA. */
However, this is no actual entry for alias set zero. It is an
error to attempt to explicitly construct a subset of zero. */
-typedef struct alias_set_entry {
+typedef struct alias_set_entry
+{
/* The alias set number, as stored in MEM_ALIAS_SET. */
int alias_set;
@@ -75,7 +76,7 @@ typedef struct alias_set_entry {
continuing our example above, the children here will be all of
`int', `double', `float', and `struct S'. */
splay_tree children;
-}* alias_set_entry;
+} *alias_set_entry;
static rtx canon_rtx PROTO((rtx));
static int rtx_equal_for_memref_p PROTO((rtx, rtx));
@@ -98,6 +99,7 @@ static int nonlocal_reference_p PROTO((rtx));
/* Set up all info needed to perform alias analysis on memory references. */
+/* Returns the size in bytes of the mode of X. */
#define SIZE_FOR_MODE(X) (GET_MODE_SIZE (GET_MODE (X)))
/* Returns nonzero if MEM1 and MEM2 do not alias because they are in
@@ -134,7 +136,8 @@ static int nonlocal_reference_p PROTO((rtx));
static rtx *reg_base_value;
static rtx *new_reg_base_value;
-static unsigned int reg_base_value_size; /* size of reg_base_value array */
+static unsigned int reg_base_value_size; /* size of reg_base_value array */
+
#define REG_BASE_VALUE(X) \
((unsigned) REGNO (X) < reg_base_value_size ? reg_base_value[REGNO (X)] : 0)
@@ -184,10 +187,10 @@ static alias_set_entry
get_alias_set_entry (alias_set)
int alias_set;
{
- splay_tree_node sn =
- splay_tree_lookup (alias_sets, (splay_tree_key) alias_set);
+ splay_tree_node sn
+ = splay_tree_lookup (alias_sets, (splay_tree_key) alias_set);
- return sn ? ((alias_set_entry) sn->value) : ((alias_set_entry) 0);
+ return sn != 0 ? ((alias_set_entry) sn->value) : 0;
}
/* Returns nonzero value if the alias sets for MEM1 and MEM2 are such
@@ -208,8 +211,8 @@ mems_in_disjoint_alias_sets_p (mem1, mem2)
gen_rtx_MEM, and the MEM_ALIAS_SET is not cleared. If we begin to
use alias sets to indicate that spilled registers cannot alias each
other, we might need to remove this check. */
- if (!flag_strict_aliasing &&
- (MEM_ALIAS_SET (mem1) || MEM_ALIAS_SET (mem2)))
+ if (! flag_strict_aliasing
+ && (MEM_ALIAS_SET (mem1) != 0 || MEM_ALIAS_SET (mem2) != 0))
abort ();
#endif
@@ -222,26 +225,26 @@ mems_in_disjoint_alias_sets_p (mem1, mem2)
if (current_function_stdarg || current_function_varargs)
return 0;
- if (!MEM_ALIAS_SET (mem1) || !MEM_ALIAS_SET (mem2))
- /* We have no alias set information for one of the MEMs, so we
- have to assume it can alias anything. */
+ /* If have no alias set information for one of the MEMs, we have to assume
+ it can alias anything. */
+ if (MEM_ALIAS_SET (mem1) == 0 || MEM_ALIAS_SET (mem2) == 0)
return 0;
+ /* If the two alias sets are the same, they may alias. */
if (MEM_ALIAS_SET (mem1) == MEM_ALIAS_SET (mem2))
- /* The two alias sets are the same, so they may alias. */
return 0;
/* Iterate through each of the children of the first alias set,
comparing it with the second alias set. */
ase = get_alias_set_entry (MEM_ALIAS_SET (mem1));
- if (ase && splay_tree_lookup (ase->children,
- (splay_tree_key) MEM_ALIAS_SET (mem2)))
+ if (ase != 0 && splay_tree_lookup (ase->children,
+ (splay_tree_key) MEM_ALIAS_SET (mem2)))
return 0;
/* Now do the same, but with the alias sets reversed. */
ase = get_alias_set_entry (MEM_ALIAS_SET (mem2));
- if (ase && splay_tree_lookup (ase->children,
- (splay_tree_key) MEM_ALIAS_SET (mem1)))
+ if (ase != 0 && splay_tree_lookup (ase->children,
+ (splay_tree_key) MEM_ALIAS_SET (mem1)))
return 0;
/* The two MEMs are in distinct alias sets, and neither one is the
@@ -257,9 +260,7 @@ insert_subset_children (node, data)
splay_tree_node node;
void *data;
{
- splay_tree_insert ((splay_tree) data,
- node->key,
- node->value);
+ splay_tree_insert ((splay_tree) data, node->key, node->value);
return 0;
}
@@ -286,33 +287,32 @@ record_alias_subset (superset, subset)
abort ();
superset_entry = get_alias_set_entry (superset);
- if (!superset_entry)
+ if (superset_entry == 0)
{
/* Create an entry for the SUPERSET, so that we have a place to
attach the SUBSET. */
- superset_entry =
- (alias_set_entry) xmalloc (sizeof (struct alias_set_entry));
+ superset_entry
+ = (alias_set_entry) xmalloc (sizeof (struct alias_set_entry));
superset_entry->alias_set = superset;
superset_entry->children
= splay_tree_new (splay_tree_compare_ints, 0, 0);
- splay_tree_insert (alias_sets,
- (splay_tree_key) superset,
+ splay_tree_insert (alias_sets, (splay_tree_key) superset,
(splay_tree_value) superset_entry);
}
subset_entry = get_alias_set_entry (subset);
+
+ /* If there is an entry for the subset, enter all of its children
+ (if they are not already present) as children of the SUPERSET. */
if (subset_entry)
- /* There is an entry for the subset. Enter all of its children
- (if they are not already present) as children of the SUPERSET. */
splay_tree_foreach (subset_entry->children,
insert_subset_children,
superset_entry->children);
/* Enter the SUBSET itself as a child of the SUPERSET. */
splay_tree_insert (superset_entry->children,
- (splay_tree_key) subset,
- /*value=*/0);
+ (splay_tree_key) subset, 0);
}
/* Inside SRC, the source of a SET, find a base address. */
@@ -328,7 +328,7 @@ find_base_value (src)
return src;
case REG:
- /* At the start of a function argument registers have known base
+ /* At the start of a function, argument registers have known base
values which may be lost later. Returning an ADDRESS
expression here allows optimization based on argument values
even when the argument registers are used for other purposes. */
@@ -363,7 +363,8 @@ find_base_value (src)
src = XEXP (src, 0);
if (GET_CODE (src) != PLUS && GET_CODE (src) != MINUS)
break;
- /* fall through */
+
+ /* ... fall through ... */
case PLUS:
case MINUS:
@@ -375,42 +376,31 @@ find_base_value (src)
if (GET_CODE (src_0) == REG)
{
temp = find_base_value (src_0);
- if (temp)
+ if (temp != 0)
src_0 = temp;
}
if (GET_CODE (src_1) == REG)
{
temp = find_base_value (src_1);
- if (temp)
+ if (temp!= 0)
src_1 = temp;
}
- /* Guess which operand is the base address.
-
+ /* Guess which operand is the base address:
If either operand is a symbol, then it is the base. If
either operand is a CONST_INT, then the other is the base. */
-
- if (GET_CODE (src_1) == CONST_INT
- || GET_CODE (src_0) == SYMBOL_REF
- || GET_CODE (src_0) == LABEL_REF
- || GET_CODE (src_0) == CONST)
+ if (GET_CODE (src_1) == CONST_INT || CONSTANT_P (src_0))
return find_base_value (src_0);
-
- if (GET_CODE (src_0) == CONST_INT
- || GET_CODE (src_1) == SYMBOL_REF
- || GET_CODE (src_1) == LABEL_REF
- || GET_CODE (src_1) == CONST)
+ else if (GET_CODE (src_0) == CONST_INT || CONSTANT_P (src_1))
return find_base_value (src_1);
- /* This might not be necessary anymore.
-
+ /* This might not be necessary anymore:
If either operand is a REG that is a known pointer, then it
is the base. */
- if (GET_CODE (src_0) == REG && REGNO_POINTER_FLAG (REGNO (src_0)))
+ else if (GET_CODE (src_0) == REG && REGNO_POINTER_FLAG (REGNO (src_0)))
return find_base_value (src_0);
-
- if (GET_CODE (src_1) == REG && REGNO_POINTER_FLAG (REGNO (src_1)))
+ else if (GET_CODE (src_1) == REG && REGNO_POINTER_FLAG (REGNO (src_1)))
return find_base_value (src_1);
return 0;
@@ -442,7 +432,7 @@ find_base_value (src)
/* Called from init_alias_analysis indirectly through note_stores. */
-/* while scanning insns to find base values, reg_seen[N] is nonzero if
+/* While scanning insns to find base values, reg_seen[N] is nonzero if
register N has been set in this function. */
static char *reg_seen;
@@ -523,6 +513,7 @@ record_set (dest, set, data)
}
/* Called from loop optimization when a new pseudo-register is created. */
+
void
record_base_value (regno, val, invariant)
int regno;
@@ -541,11 +532,11 @@ record_base_value (regno, val, invariant)
if (GET_CODE (val) == REG)
{
if ((unsigned) REGNO (val) < reg_base_value_size)
- {
- reg_base_value[regno] = reg_base_value[REGNO (val)];
- }
+ reg_base_value[regno] = reg_base_value[REGNO (val)];
+
return;
}
+
reg_base_value[regno] = find_base_value (val);
}
@@ -574,6 +565,7 @@ canon_rtx (x)
return gen_rtx_PLUS (GET_MODE (x), x0, x1);
}
}
+
/* This gives us much better alias analysis when called from
the loop optimizer. Note we want to leave the original
MEM alone, but need to return the canonicalized MEM with
@@ -581,9 +573,11 @@ canon_rtx (x)
else if (GET_CODE (x) == MEM)
{
rtx addr = canon_rtx (XEXP (x, 0));
+
if (addr != XEXP (x, 0))
{
rtx new = gen_rtx_MEM (GET_MODE (x), addr);
+
RTX_UNCHANGING_P (new) = RTX_UNCHANGING_P (x);
MEM_COPY_ATTRIBUTES (new, x);
MEM_ALIAS_SET (new) = MEM_ALIAS_SET (x);
@@ -611,6 +605,7 @@ rtx_equal_for_memref_p (x, y)
return 1;
if (x == 0 || y == 0)
return 0;
+
x = canon_rtx (x);
y = canon_rtx (y);
@@ -643,7 +638,8 @@ rtx_equal_for_memref_p (x, y)
if (code == CONST_DOUBLE)
return 0;
if (code == ADDRESSOF)
- return REGNO (XEXP (x, 0)) == REGNO (XEXP (y, 0)) && XINT (x, 1) == XINT (y, 1);
+ return (REGNO (XEXP (x, 0)) == REGNO (XEXP (y, 0))
+ && XINT (x, 1) == XINT (y, 1));
/* For commutative operations, the RTX match if the operand match in any
order. Also handle the simple binary and unary cases without a loop. */
@@ -680,7 +676,8 @@ rtx_equal_for_memref_p (x, y)
/* And the corresponding elements must match. */
for (j = 0; j < XVECLEN (x, i); j++)
- if (rtx_equal_for_memref_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
+ if (rtx_equal_for_memref_p (XVECEXP (x, i, j),
+ XVECEXP (y, i, j)) == 0)
return 0;
break;
@@ -795,14 +792,14 @@ find_base_term (x)
/* If either base term is named object or a special address
(like an argument or stack reference), then use it for the
base term. */
- if (tmp1
+ if (tmp1 != 0
&& (GET_CODE (tmp1) == SYMBOL_REF
|| GET_CODE (tmp1) == LABEL_REF
|| (GET_CODE (tmp1) == ADDRESS
&& GET_MODE (tmp1) != VOIDmode)))
return tmp1;
- if (tmp2
+ if (tmp2 != 0
&& (GET_CODE (tmp2) == SYMBOL_REF
|| GET_CODE (tmp2) == LABEL_REF
|| (GET_CODE (tmp2) == ADDRESS
@@ -846,8 +843,10 @@ base_alias_check (x, y, x_mode, y_mode)
if (x_base == 0)
{
rtx x_c;
+
if (! flag_expensive_optimizations || (x_c = canon_rtx (x)) == x)
return 1;
+
x_base = find_base_term (x_c);
if (x_base == 0)
return 1;
@@ -858,6 +857,7 @@ base_alias_check (x, y, x_mode, y_mode)
rtx y_c;
if (! flag_expensive_optimizations || (y_c = canon_rtx (y)) == y)
return 1;
+
y_base = find_base_term (y_c);
if (y_base == 0)
return 1;