aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2005-11-19 21:37:08 -0800
committerRichard Henderson <rth@gcc.gnu.org>2005-11-19 21:37:08 -0800
commit688e936d4666ef4f439810756d094a61b6f22186 (patch)
tree122db954d6114e9b5e9bf6c18c520145c59570fa /gcc/tree-ssa-ccp.c
parent7ab1122a479d64423c6ad069793f41666f9fd3aa (diff)
downloadgcc-688e936d4666ef4f439810756d094a61b6f22186.zip
gcc-688e936d4666ef4f439810756d094a61b6f22186.tar.gz
gcc-688e936d4666ef4f439810756d094a61b6f22186.tar.bz2
re PR tree-optimization/24665 (internal compiler error: get_indirect_ref_operands)
PR tree-opt/24665 * tree-gimple.c (is_gimple_id): Export. * tree-gimple.h (is_gimple_id): Declare. * tree-ssa-ccp.c (ccp_decl_initial_min_invariant): New. (get_default_value): Use it. (maybe_fold_stmt_indirect): Likewise. From-SVN: r107244
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index e9e1c0b..cd446ee 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -273,6 +273,32 @@ debug_lattice_value (prop_value_t val)
}
+/* The regular is_gimple_min_invariant does a shallow test of the object.
+ It assumes that full gimplification has happened, or will happen on the
+ object. For a value coming from DECL_INITIAL, this is not true, so we
+ have to be more strict outselves. */
+
+static bool
+ccp_decl_initial_min_invariant (tree t)
+{
+ if (!is_gimple_min_invariant (t))
+ return false;
+ if (TREE_CODE (t) == ADDR_EXPR)
+ {
+ /* Inline and unroll is_gimple_addressable. */
+ while (1)
+ {
+ t = TREE_OPERAND (t, 0);
+ if (is_gimple_id (t))
+ return true;
+ if (!handled_component_p (t))
+ return false;
+ }
+ }
+ return true;
+}
+
+
/* Compute a default value for variable VAR and store it in the
CONST_VAL array. The following rules are used to get default
values:
@@ -317,7 +343,7 @@ get_default_value (tree var)
else if (TREE_STATIC (sym)
&& TREE_READONLY (sym)
&& DECL_INITIAL (sym)
- && is_gimple_min_invariant (DECL_INITIAL (sym)))
+ && ccp_decl_initial_min_invariant (DECL_INITIAL (sym)))
{
/* Globals and static variables declared 'const' take their
initial value. */
@@ -1712,7 +1738,7 @@ maybe_fold_stmt_indirect (tree expr, tree base, tree offset)
/* Fold away CONST_DECL to its value, if the type is scalar. */
if (TREE_CODE (base) == CONST_DECL
- && is_gimple_min_invariant (DECL_INITIAL (base)))
+ && ccp_decl_initial_min_invariant (DECL_INITIAL (base)))
return DECL_INITIAL (base);
/* Try folding *(&B+O) to B[X]. */