[PATCH] Do not recompute_tree_invariant_for_addr_expr
Richard Guenther
rguenther@suse.de
Sat Mar 22 21:35:00 GMT 2008
On Thu, 20 Mar 2008, Richard Guenther wrote:
> On Thu, 20 Mar 2008, Jakub Jelinek wrote:
>
> > On Thu, Mar 20, 2008 at 11:16:39PM +0100, Richard Guenther wrote:
> > >
> > > As we switched is_gimple_min_invariant to re-check its property at
> > > every call we no longer need to keep the cache (TREE_INVARIANT)
> > > up-to-date.
> >
> > You are not touching just TREE_INVARIANT, but also TREE_CONSTANT.
> > Are you sure it is ok to keep an ADDR_EXPR TREE_CONSTANT when it is no
> > longer constant?
> > E.g. omp-low.c can change TREE_CONSTANT ADDR_EXPRs (e.g. &global_var)
> > into non-constant ADDR_EXPRs (&.omp_data_i->global_var).
>
> I briefly went over the uses of TREE_CONSTANT in the middle-end and
> decided it will not matter. But I'll check again and try to replace
> those that don't look right.
>
> Thanks for the heads up.
This is what I committed instead. Bootstrapped and tested on
x86_64-unknown-linux-gnu.
Richard.
2008-03-20 Richard Guenther <rguenther@suse.de>
* tree-cfg.c (verify_expr): Recurse again for invariant addresses.
For PHI nodes verify the address is invariant.
* tree-ssa-ccp.c (ccp_decl_initial_min_invariant): Remove.
(get_symbol_constant_value): Use is_gimple_min_invariant.
(maybe_fold_stmt_indirect): Likewise.
Index: trunk/gcc/tree-cfg.c
===================================================================
*** trunk.orig/gcc/tree-cfg.c 2008-03-20 22:30:58.000000000 +0100
--- trunk/gcc/tree-cfg.c 2008-03-22 19:22:19.000000000 +0100
*************** verify_expr (tree *tp, int *walk_subtree
*** 3172,3178 ****
we may be missing "valid" checks, but what can you do?
This was PR19217. */
if (in_phi)
! break;
old_invariant = TREE_INVARIANT (t);
old_constant = TREE_CONSTANT (t);
--- 3172,3185 ----
we may be missing "valid" checks, but what can you do?
This was PR19217. */
if (in_phi)
! {
! if (!is_gimple_min_invariant (t))
! {
! error ("non-invariant address expression in PHI argument");
! return t;
! }
! break;
! }
old_invariant = TREE_INVARIANT (t);
old_constant = TREE_CONSTANT (t);
*************** verify_expr (tree *tp, int *walk_subtree
*** 3216,3225 ****
return x;
}
- /* Stop recursing and verifying invariant ADDR_EXPRs, they tend
- to become arbitrary complicated. */
- if (is_gimple_min_invariant (t))
- *walk_subtrees = 0;
break;
}
--- 3223,3228 ----
Index: trunk/gcc/tree-ssa-ccp.c
===================================================================
*** trunk.orig/gcc/tree-ssa-ccp.c 2008-03-21 00:15:54.000000000 +0100
--- trunk/gcc/tree-ssa-ccp.c 2008-03-22 19:20:58.000000000 +0100
*************** debug_lattice_value (prop_value_t val)
*** 267,297 ****
}
- /* 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 ourselves. */
-
- 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;
- }
-
/* If SYM is a constant variable with known value, return the value.
NULL_TREE is returned otherwise. */
--- 267,272 ----
*************** get_symbol_constant_value (tree sym)
*** 304,310 ****
{
tree val = DECL_INITIAL (sym);
if (val
! && ccp_decl_initial_min_invariant (val))
return val;
/* Variables declared 'const' without an initializer
have zero as the intializer if they may not be
--- 279,285 ----
{
tree val = DECL_INITIAL (sym);
if (val
! && is_gimple_min_invariant (val))
return val;
/* Variables declared 'const' without an initializer
have zero as the intializer if they may not be
*************** maybe_fold_stmt_indirect (tree expr, tre
*** 1888,1894 ****
/* Fold away CONST_DECL to its value, if the type is scalar. */
if (TREE_CODE (base) == CONST_DECL
! && ccp_decl_initial_min_invariant (DECL_INITIAL (base)))
return DECL_INITIAL (base);
/* Try folding *(&B+O) to B.X. */
--- 1863,1869 ----
/* 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)))
return DECL_INITIAL (base);
/* Try folding *(&B+O) to B.X. */
More information about the Gcc-patches
mailing list