Commit 15fda317 by Sebastian Pop Committed by Sebastian Pop

tree-scalar-evolution.c (instantiate_scev_binary): New.

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

	* tree-scalar-evolution.c (instantiate_scev_binary): New.
	(instantiate_scev_1): Move code in instantiate_scev_binary.

From-SVN: r154533
parent 320f5a78
2009-09-01 Sebastian Pop <sebastian.pop@amd.com> 2009-09-01 Sebastian Pop <sebastian.pop@amd.com>
* tree-scalar-evolution.c (instantiate_scev_binary): New.
(instantiate_scev_1): Move code in instantiate_scev_binary.
2009-09-01 Sebastian Pop <sebastian.pop@amd.com>
* tree-scalar-evolution.c (instantiate_scev_name): New. * tree-scalar-evolution.c (instantiate_scev_name): New.
(instantiate_scev_1): Move code in instantiate_scev_name. (instantiate_scev_1): Move code in instantiate_scev_name.
......
...@@ -2192,6 +2192,66 @@ instantiate_scev_name (basic_block instantiate_below, ...@@ -2192,6 +2192,66 @@ instantiate_scev_name (basic_block instantiate_below,
} }
/* 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.
CHREC is a binary expression 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_binary (basic_block instantiate_below,
struct loop *evolution_loop, tree chrec,
bool fold_conversions, htab_t cache, int size_expr)
{
tree op1;
tree op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 0), fold_conversions, cache,
size_expr);
if (op0 == chrec_dont_know)
return chrec_dont_know;
op1 = instantiate_scev_1 (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 1), fold_conversions, cache,
size_expr);
if (op1 == chrec_dont_know)
return chrec_dont_know;
if (TREE_OPERAND (chrec, 0) != op0
|| TREE_OPERAND (chrec, 1) != op1)
{
tree type = chrec_type (chrec);
op0 = chrec_convert (type, op0, NULL);
op1 = chrec_convert_rhs (type, op1, NULL);
switch (TREE_CODE (chrec))
{
case POINTER_PLUS_EXPR:
case PLUS_EXPR:
return chrec_fold_plus (type, op0, op1);
case MINUS_EXPR:
return chrec_fold_minus (type, op0, op1);
case MULT_EXPR:
return chrec_fold_multiply (type, op0, op1);
default:
gcc_unreachable ();
}
}
return chrec;
}
/* 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.
CHREC is the scalar evolution to instantiate. CHREC is the scalar evolution to instantiate.
...@@ -2250,70 +2310,10 @@ instantiate_scev_1 (basic_block instantiate_below, ...@@ -2250,70 +2310,10 @@ instantiate_scev_1 (basic_block instantiate_below,
case POINTER_PLUS_EXPR: case POINTER_PLUS_EXPR:
case PLUS_EXPR: case PLUS_EXPR:
op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 0), fold_conversions, cache,
size_expr);
if (op0 == chrec_dont_know)
return chrec_dont_know;
op1 = instantiate_scev_1 (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 1), fold_conversions, cache,
size_expr);
if (op1 == chrec_dont_know)
return chrec_dont_know;
if (TREE_OPERAND (chrec, 0) != op0
|| TREE_OPERAND (chrec, 1) != op1)
{
op0 = chrec_convert (type, op0, NULL);
op1 = chrec_convert_rhs (type, op1, NULL);
chrec = chrec_fold_plus (type, op0, op1);
}
return chrec;
case MINUS_EXPR: case MINUS_EXPR:
op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 0), fold_conversions, cache,
size_expr);
if (op0 == chrec_dont_know)
return chrec_dont_know;
op1 = instantiate_scev_1 (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 1),
fold_conversions, cache, size_expr);
if (op1 == chrec_dont_know)
return chrec_dont_know;
if (TREE_OPERAND (chrec, 0) != op0
|| TREE_OPERAND (chrec, 1) != op1)
{
op0 = chrec_convert (type, op0, NULL);
op1 = chrec_convert (type, op1, NULL);
chrec = chrec_fold_minus (type, op0, op1);
}
return chrec;
case MULT_EXPR: case MULT_EXPR:
op0 = instantiate_scev_1 (instantiate_below, evolution_loop, return instantiate_scev_binary (instantiate_below, evolution_loop, chrec,
TREE_OPERAND (chrec, 0), fold_conversions, cache, size_expr);
fold_conversions, cache, size_expr);
if (op0 == chrec_dont_know)
return chrec_dont_know;
op1 = instantiate_scev_1 (instantiate_below, evolution_loop,
TREE_OPERAND (chrec, 1),
fold_conversions, cache, size_expr);
if (op1 == chrec_dont_know)
return chrec_dont_know;
if (TREE_OPERAND (chrec, 0) != op0
|| TREE_OPERAND (chrec, 1) != op1)
{
op0 = chrec_convert (type, op0, NULL);
op1 = chrec_convert (type, op1, NULL);
chrec = chrec_fold_multiply (type, op0, op1);
}
return chrec;
CASE_CONVERT: CASE_CONVERT:
op0 = instantiate_scev_1 (instantiate_below, evolution_loop, op0 = instantiate_scev_1 (instantiate_below, evolution_loop,
...@@ -2363,7 +2363,7 @@ instantiate_scev_1 (basic_block instantiate_below, ...@@ -2363,7 +2363,7 @@ instantiate_scev_1 (basic_block instantiate_below,
case SCEV_KNOWN: case SCEV_KNOWN:
return chrec_known; return chrec_known;
default: default:
break; break;
} }
......
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