Commit 2495a183 by Sebastian Pop Committed by Sebastian Pop

Partially revert the previous patch, except the following.

2009-09-02  Sebastian Pop  <sebastian.pop@amd.com>

	Partially revert the previous patch, except the following.
	* tree-scalar-evolution.c (instantiate_scev_not): Adapted to pass
	as parameters the operands of the not expression.

From-SVN: r154542
parent 20179b0d
2009-09-02 Sebastian Pop <sebastian.pop@amd.com>
Partially revert the previous patch, except the following.
* tree-scalar-evolution.c (instantiate_scev_not): Adapted to pass
as parameters the operands of the not expression.
2009-09-01 Sebastian Pop <sebastian.pop@amd.com> 2009-09-01 Sebastian Pop <sebastian.pop@amd.com>
* tree-scalar-evolution.c (instantiate_scev_assign): New. * tree-scalar-evolution.c (instantiate_scev_assign): New.
......
...@@ -2109,21 +2109,13 @@ loop_closed_phi_def (tree var) ...@@ -2109,21 +2109,13 @@ loop_closed_phi_def (tree var)
return NULL_TREE; return NULL_TREE;
} }
static tree instantiate_scev_binary (basic_block, struct loop *, tree,
enum tree_code, tree, tree, tree,
bool, htab_t, int);
static tree instantiate_scev_convert (basic_block, struct loop *, tree, tree,
tree, bool, htab_t, int);
static tree instantiate_scev_not (basic_block, struct loop *, tree,
enum tree_code, tree, tree,
bool, htab_t, int);
static tree instantiate_scev_r (basic_block, struct loop *, tree, bool, static tree instantiate_scev_r (basic_block, struct loop *, tree, bool,
htab_t, int); htab_t, int);
/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW /* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
and EVOLUTION_LOOP, that were left under a symbolic form. and EVOLUTION_LOOP, that were left under a symbolic form.
STMT is a GIMPLE assignment to be instantiated. CHREC is an SSA_NAME to be instantiated.
CACHE is the cache of already instantiated values. CACHE is the cache of already instantiated values.
...@@ -2135,91 +2127,39 @@ static tree instantiate_scev_r (basic_block, struct loop *, tree, bool, ...@@ -2135,91 +2127,39 @@ static tree instantiate_scev_r (basic_block, struct loop *, tree, bool,
instantiated, and to stop if it exceeds some limit. */ instantiated, and to stop if it exceeds some limit. */
static tree static tree
instantiate_scev_assign (basic_block instantiate_below, instantiate_scev_name (basic_block instantiate_below,
struct loop *evolution_loop, gimple stmt, struct loop *evolution_loop, tree chrec,
bool fold_conversions, htab_t cache, int size_expr) bool fold_conversions, htab_t cache, int size_expr)
{ {
tree type = TREE_TYPE (gimple_assign_lhs (stmt)); tree res;
tree rhs1 = gimple_assign_rhs1 (stmt); struct loop *def_loop;
tree rhs2 = gimple_assign_rhs2 (stmt); basic_block def_bb = gimple_bb (SSA_NAME_DEF_STMT (chrec));
enum tree_code code = gimple_assign_rhs_code (stmt);
if (get_gimple_rhs_class (code) == GIMPLE_SINGLE_RHS)
{
if (is_gimple_min_invariant (rhs1))
return chrec_convert (type, rhs1, stmt);
if (code == SSA_NAME)
{
rhs1 = instantiate_scev_r (instantiate_below, evolution_loop, rhs1,
fold_conversions, cache, size_expr);
return chrec_convert (type, rhs1, stmt);
}
if (code == ASSERT_EXPR)
{
rhs1 = ASSERT_EXPR_VAR (rhs1);
rhs1 = instantiate_scev_r (instantiate_below, evolution_loop, rhs1,
fold_conversions, cache, size_expr);
return chrec_convert (type, rhs1, stmt);
}
return chrec_dont_know;
}
switch (code)
{
case POINTER_PLUS_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
case MULT_EXPR:
return instantiate_scev_binary (instantiate_below, evolution_loop,
NULL_TREE, code, type, rhs1, rhs2,
fold_conversions, cache, size_expr);
case NEGATE_EXPR:
case BIT_NOT_EXPR:
return instantiate_scev_not (instantiate_below, evolution_loop,
NULL_TREE, code, type, rhs1,
fold_conversions, cache, size_expr);
CASE_CONVERT:
return instantiate_scev_convert (instantiate_below, evolution_loop,
NULL_TREE, type, rhs1,
fold_conversions, cache, size_expr);
default:
return chrec_dont_know;
}
}
/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
and EVOLUTION_LOOP, that were left under a symbolic form.
CHREC is an SSA_NAME defined by a GIMPLE PHI node. As the PHI node
belongs to the region to be instantiated, it is fully analyzed and
transformed into a chain of recurrence.
CACHE is the cache of already instantiated values. /* A parameter (or loop invariant and we do not want to include
evolutions in outer loops), nothing to do. */
if (!def_bb
|| loop_depth (def_bb->loop_father) == 0
|| dominated_by_p (CDI_DOMINATORS, instantiate_below, def_bb))
return chrec;
FOLD_CONVERSIONS should be set to true when the conversions that /* We cache the value of instantiated variable to avoid exponential
may wrap in signed/pointer type are folded, as long as the value of time complexity due to reevaluations. We also store the convenient
the chrec is preserved. value in the cache in order to prevent infinite recursion -- we do
not want to instantiate the SSA_NAME if it is in a mixer
structure. This is used for avoiding the instantiation of
recursively defined functions, such as:
SIZE_EXPR is used for computing the size of the expression to be | a_2 -> {0, +, 1, +, a_2}_1 */
instantiated, and to stop if it exceeds some limit. */
static tree res = get_instantiated_value (cache, instantiate_below, chrec);
instantiate_scev_phi (basic_block instantiate_below, if (res)
struct loop *evolution_loop, tree chrec, return res;
bool fold_conversions, htab_t cache, int size_expr)
{
tree res = chrec_dont_know;
gimple def = SSA_NAME_DEF_STMT (chrec);
basic_block def_bb = gimple_bb (def);
loop_p def_loop = find_common_loop (evolution_loop, def_bb->loop_father);
res = chrec_dont_know;
set_instantiated_value (cache, instantiate_below, chrec, res); set_instantiated_value (cache, instantiate_below, chrec, res);
def_loop = find_common_loop (evolution_loop, def_bb->loop_father);
/* If the analysis yields a parametric chrec, instantiate the /* If the analysis yields a parametric chrec, instantiate the
result again. */ result again. */
res = analyze_scalar_evolution (def_loop, chrec); res = analyze_scalar_evolution (def_loop, chrec);
...@@ -2248,63 +2188,7 @@ instantiate_scev_phi (basic_block instantiate_below, ...@@ -2248,63 +2188,7 @@ instantiate_scev_phi (basic_block instantiate_below,
/* Store the correct value to the cache. */ /* Store the correct value to the cache. */
set_instantiated_value (cache, instantiate_below, chrec, res); set_instantiated_value (cache, instantiate_below, chrec, res);
return res; return res;
}
/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
and EVOLUTION_LOOP, that were left under a symbolic form.
CHREC is an SSA_NAME to be instantiated.
CACHE is the cache of already instantiated values.
FOLD_CONVERSIONS should be set to true when the conversions that
may wrap in signed/pointer type are folded, as long as the value of
the chrec is preserved.
SIZE_EXPR is used for computing the size of the expression to be
instantiated, and to stop if it exceeds some limit. */
static tree
instantiate_scev_name (basic_block instantiate_below,
struct loop *evolution_loop, tree chrec,
bool fold_conversions, htab_t cache, int size_expr)
{
tree res;
gimple def = SSA_NAME_DEF_STMT (chrec);
basic_block def_bb = gimple_bb (def);
/* A parameter (or loop invariant and we do not want to include
evolutions in outer loops), nothing to do. */
if (!def_bb
|| loop_depth (def_bb->loop_father) == 0
|| dominated_by_p (CDI_DOMINATORS, instantiate_below, def_bb))
return chrec;
/* We cache the value of instantiated variable to avoid exponential
time complexity due to reevaluations. We also store the convenient
value in the cache in order to prevent infinite recursion -- we do
not want to instantiate the SSA_NAME if it is in a mixer
structure. This is used for avoiding the instantiation of
recursively defined functions, such as:
| a_2 -> {0, +, 1, +, a_2}_1 */
res = get_instantiated_value (cache, instantiate_below, chrec);
if (res)
return res;
/* Return the RHS */
switch (gimple_code (def))
{
case GIMPLE_ASSIGN:
return instantiate_scev_assign (instantiate_below, evolution_loop, def,
fold_conversions, cache, size_expr);
case GIMPLE_PHI:
return instantiate_scev_phi (instantiate_below, evolution_loop, chrec,
fold_conversions, cache, size_expr);
default:
return chrec_dont_know;
}
} }
/* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW /* Analyze all the parameters of the chrec, between INSTANTIATE_BELOW
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment