aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-03-11 05:07:18 +0000
committerRichard Henderson <rth@redhat.com>2004-03-11 05:07:18 +0000
commit3c66591005049818d41d716bfcf6a8bf6e64df95 (patch)
tree761aa58baa09872e5ed12b61459e9c43ad2cbd5c
parente1e2a89225c9c50c6da15a96e26e9088a9fefa3b (diff)
* tree-simple.c (get_base_var, get_base_decl): Remove.
* tree-simple.h: Likewise. * tree-dfa.c (discover_nonconstant_array_refs_r): Use get_base_address. * tree-ssa-alias.c (ptr_is_dereferenced_by): Likewise. (add_pointed_to_var, is_escape_site): Likewise. * tree-ssa-ccp.c (get_default_value): Expect only SSA_NAME and DECLs. * tree-ssa-operands.c (add_stmt_operand): Likewise. (note_addressable): Use get_base_address. * tree-ssa-dce.c (need_to_preserve_store): Expect only SSA_NAME. * tree-ssa.c (set_is_used): Inline get_base_decl. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@79301 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog.tree-ssa13
-rw-r--r--gcc/tree-dfa.c2
-rw-r--r--gcc/tree-simple.c46
-rw-r--r--gcc/tree-simple.h2
-rw-r--r--gcc/tree-ssa-alias.c25
-rw-r--r--gcc/tree-ssa-ccp.c11
-rw-r--r--gcc/tree-ssa-dce.c4
-rw-r--r--gcc/tree-ssa-operands.c4
-rw-r--r--gcc/tree-ssa.c24
9 files changed, 67 insertions, 64 deletions
diff --git a/gcc/ChangeLog.tree-ssa b/gcc/ChangeLog.tree-ssa
index cebd082b67f..97f7a172bab 100644
--- a/gcc/ChangeLog.tree-ssa
+++ b/gcc/ChangeLog.tree-ssa
@@ -1,5 +1,18 @@
2004-03-10 Richard Henderson <rth@redhat.com>
+ * tree-simple.c (get_base_var, get_base_decl): Remove.
+ * tree-simple.h: Likewise.
+ * tree-dfa.c (discover_nonconstant_array_refs_r): Use get_base_address.
+ * tree-ssa-alias.c (ptr_is_dereferenced_by): Likewise.
+ (add_pointed_to_var, is_escape_site): Likewise.
+ * tree-ssa-ccp.c (get_default_value): Expect only SSA_NAME and DECLs.
+ * tree-ssa-operands.c (add_stmt_operand): Likewise.
+ (note_addressable): Use get_base_address.
+ * tree-ssa-dce.c (need_to_preserve_store): Expect only SSA_NAME.
+ * tree-ssa.c (set_is_used): Inline get_base_decl.
+
+2004-03-10 Richard Henderson <rth@redhat.com>
+
* tree-nested.c (convert_nonlocal_reference): Clear TREE_INVARIANT
on modified ADDR_EXPRs.
diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c
index d6ccce764db..787a30c0268 100644
--- a/gcc/tree-dfa.c
+++ b/gcc/tree-dfa.c
@@ -1295,7 +1295,7 @@ discover_nonconstant_array_refs_r (tree * tp, int *walk_subtrees,
t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) == ARRAY_REF)
{
- t = get_base_decl (t);
+ t = get_base_address (t);
if (t && DECL_P (t))
TREE_ADDRESSABLE (t) = 1;
}
diff --git a/gcc/tree-simple.c b/gcc/tree-simple.c
index bcca3df65ca..e2d313a1b05 100644
--- a/gcc/tree-simple.c
+++ b/gcc/tree-simple.c
@@ -587,52 +587,6 @@ rationalize_compound_expr (tree top)
return top;
}
-/* Given a GIMPLE variable or memory reference T (e.g., ID, an ARRAY_REF, an
- INDIRECT_REF), return the base variable of T (either a _DECL or an
- SSA_NAME). If T is not a variable or a memory reference, NULL_TREE is
- returned. */
-
-tree
-get_base_var (tree t)
-{
- do
- {
- if (SSA_VAR_P (t))
- return t;
-
- switch (TREE_CODE (t))
- {
- case ARRAY_REF:
- case COMPONENT_REF:
- case REALPART_EXPR:
- case IMAGPART_EXPR:
- case INDIRECT_REF:
- t = TREE_OPERAND (t, 0);
- break;
-
- default:
- return NULL_TREE;
- }
- }
- while (t);
-
- return t;
-}
-
-/* Given a GIMPLE variable or memory reference T, return the base _DECL
- symbol. If T is not a variable or memory reference, NULL_TREE is
- returned. */
-
-tree
-get_base_decl (tree t)
-{
- t = get_base_var (t);
- if (t && TREE_CODE (t) == SSA_NAME)
- return SSA_NAME_VAR (t);
-
- return t;
-}
-
/* Given a memory reference expression, return the base address. Note that,
in contrast with get_base_var, this will not recurse inside INDIRECT_REF
expressions. Therefore, given the reference PTR->FIELD, this function
diff --git a/gcc/tree-simple.h b/gcc/tree-simple.h
index 5093d302000..d2c91032031 100644
--- a/gcc/tree-simple.h
+++ b/gcc/tree-simple.h
@@ -108,8 +108,6 @@ void push_gimplify_context (void);
void pop_gimplify_context (tree);
/* Miscellaneous helpers. */
-tree get_base_decl (tree);
-tree get_base_var (tree);
tree get_base_address (tree t);
void gimple_add_tmp_var (tree);
tree gimple_current_bind_expr (void);
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index a94ef13ec0d..4f1f4377b31 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -449,10 +449,20 @@ ptr_is_dereferenced_by (tree ptr, tree stmt)
lhs = TREE_OPERAND (e, 0);
rhs = TREE_OPERAND (e, 1);
- return ((TREE_CODE_CLASS (TREE_CODE (lhs)) == 'r'
- && get_base_var (lhs) == ptr)
- || (TREE_CODE_CLASS (TREE_CODE (rhs)) == 'r'
- && get_base_var (rhs) == ptr));
+ if (TREE_CODE_CLASS (TREE_CODE (lhs)) == 'r')
+ {
+ lhs = get_base_address (lhs);
+ if (lhs && TREE_CODE (lhs) == INDIRECT_REF
+ && TREE_OPERAND (lhs, 0) == ptr)
+ return true;
+ }
+ if (TREE_CODE_CLASS (TREE_CODE (rhs)) == 'r')
+ {
+ rhs = get_base_address (rhs);
+ if (rhs && TREE_CODE (rhs) == INDIRECT_REF
+ && TREE_OPERAND (rhs, 0) == ptr)
+ return true;
+ }
}
return false;
@@ -1405,7 +1415,7 @@ add_pointed_to_var (struct alias_info *ai, tree ptr, tree value)
pt_var = TREE_OPERAND (value, 0);
if (TREE_CODE_CLASS (TREE_CODE (pt_var)) == 'r')
- pt_var = get_base_decl (pt_var);
+ pt_var = get_base_address (pt_var);
if (pt_var && SSA_VAR_P (pt_var))
{
@@ -1550,7 +1560,7 @@ is_escape_site (tree stmt, size_t *num_calls_p)
/* Get to the base of _REF nodes. */
if (TREE_CODE (lhs) != SSA_NAME)
- lhs = get_base_var (lhs);
+ lhs = get_base_address (lhs);
/* If we couldn't recognize the LHS of the assignment, assume that it
is a non-local store. */
@@ -1562,9 +1572,6 @@ is_escape_site (tree stmt, size_t *num_calls_p)
if (TREE_CODE (lhs) == SSA_NAME)
return false;
- if (!DECL_P (lhs))
- abort ();
-
/* FIXME: LHS is not an SSA_NAME. Even if it's an assignment to a
local variables we cannot be sure if it will escape, because we
don't have information about objects not in SSA form. Need to
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 8576ca558ef..e9a5a24780c 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1987,7 +1987,16 @@ get_default_value (tree var)
value val;
tree sym;
- sym = (!DECL_P (var)) ? get_base_decl (var) : var;
+ if (TREE_CODE (var) == SSA_NAME)
+ sym = SSA_NAME_VAR (var);
+ else
+ {
+#ifdef ENABLE_CHECKING
+ if (!DECL_P (var))
+ abort ();
+#endif
+ sym = var;
+ }
val.lattice_val = UNDEFINED;
val.const_val = NULL_TREE;
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index e82880a0206..effc148a844 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -270,9 +270,9 @@ mark_operand_necessary (tree op)
/* Return true if a store to a variable needs to be preserved. */
static inline bool
-need_to_preserve_store (tree var)
+need_to_preserve_store (tree ssa_name)
{
- return (needs_to_live_in_memory (get_base_decl (var)));
+ return (needs_to_live_in_memory (SSA_NAME_VAR (ssa_name)));
}
diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c
index 8d77dac872c..e9a3413c919 100644
--- a/gcc/tree-ssa-operands.c
+++ b/gcc/tree-ssa-operands.c
@@ -1156,7 +1156,7 @@ add_stmt_operand (tree *var_p, tree stmt, int flags, voperands_t prev_vops)
if (var == NULL_TREE || !SSA_VAR_P (var))
return;
- sym = get_base_decl (var);
+ sym = (TREE_CODE (var) == SSA_NAME ? SSA_NAME_VAR (var) : var);
v_ann = var_ann (sym);
/* FIXME: We currently refuse to optimize variables that have hidden uses
@@ -1268,7 +1268,7 @@ add_stmt_operand (tree *var_p, tree stmt, int flags, voperands_t prev_vops)
static void
note_addressable (tree var, stmt_ann_t s_ann)
{
- var = get_base_decl (var);
+ var = get_base_address (var);
if (var && SSA_VAR_P (var))
{
if (s_ann->addresses_taken == NULL)
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 04b03d34361..cf48ea87c8f 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -3442,7 +3442,29 @@ rewrite_stmt (struct dom_walk_data *walk_data,
void
set_is_used (tree t)
{
- t = get_base_decl (t);
+ while (1)
+ {
+ if (SSA_VAR_P (t))
+ break;
+
+ switch (TREE_CODE (t))
+ {
+ case ARRAY_REF:
+ case COMPONENT_REF:
+ case REALPART_EXPR:
+ case IMAGPART_EXPR:
+ case INDIRECT_REF:
+ t = TREE_OPERAND (t, 0);
+ break;
+
+ default:
+ return;
+ }
+ }
+
+ if (TREE_CODE (t) == SSA_NAME)
+ t = SSA_NAME_VAR (t);
+
var_ann (t)->used = 1;
}