Commit e2157b49 by Sebastian Pop Committed by Sebastian Pop

tree-scalar-evolution.c (add_to_evolution_1): Pass an extra argument at_stmt.

	* tree-scalar-evolution.c (add_to_evolution_1): Pass an extra argument
	at_stmt.  Convert the type of operands before calling 
	build_polynomial_chrec.
	(add_to_evolution): Pass an extra argument at_stmt.  Adjust the call to
	add_to_evolution_1.
	(follow_ssa_edge_in_rhs): Adjust call to add_to_evolution.
	(instantiate_parameters_1): Convert the type of operands before calling 
	build_polynomial_chrec.
	* tree-chrec.c (chrec_fold_poly_cst, chrec_fold_plus_poly_poly,
	chrec_fold_multiply_poly_poly, chrec_replace_initial_condition,
	reset_evolution_in_loop): Insert asserts to check the types of the
	operands.
	(chrec_type): Moved...
	(eq_evolutions_p): Use operand_equal_p.
	* tree-chrec.h (build_polynomial_chrec): Insert an assert to check
	the types of the operands.
	(chrec_type): ...here.
	* tree-data-ref.c (create_data_ref): Convert the operands before
	calling chrec_replace_initial_condition.
	(same_access_functions, analyze_subscript_affine_affine,
	analyze_miv_subscript, all_chrecs_equal_p): Use eq_evolutions_p.
	(compute_subscript_distance, analyze_ziv_subscript,
	analyze_siv_subscript_cst_affine, compute_overlap_steps_for_affine_1_2,
	analyze_miv_subscript): Convert the operands before calling
	chrec_fold_minus or chrec_fold_plus.

From-SVN: r112621
parent a84481aa
2006-04-02 Sebastian Pop <pop@cri.ensmp.fr> 2006-04-02 Sebastian Pop <pop@cri.ensmp.fr>
* tree-scalar-evolution.c (add_to_evolution_1): Pass an extra argument
at_stmt. Convert the type of operands before calling
build_polynomial_chrec.
(add_to_evolution): Pass an extra argument at_stmt. Adjust the call to
add_to_evolution_1.
(follow_ssa_edge_in_rhs): Adjust call to add_to_evolution.
(instantiate_parameters_1): Convert the type of operands before calling
build_polynomial_chrec.
* tree-chrec.c (chrec_fold_poly_cst, chrec_fold_plus_poly_poly,
chrec_fold_multiply_poly_poly, chrec_replace_initial_condition,
reset_evolution_in_loop): Insert asserts to check the types of the
operands.
(chrec_type): Moved...
(eq_evolutions_p): Use operand_equal_p.
* tree-chrec.h (build_polynomial_chrec): Insert an assert to check
the types of the operands.
(chrec_type): ...here.
* tree-data-ref.c (create_data_ref): Convert the operands before
calling chrec_replace_initial_condition.
(same_access_functions, analyze_subscript_affine_affine,
analyze_miv_subscript, all_chrecs_equal_p): Use eq_evolutions_p.
(compute_subscript_distance, analyze_ziv_subscript,
analyze_siv_subscript_cst_affine, compute_overlap_steps_for_affine_1_2,
analyze_miv_subscript): Convert the operands before calling
chrec_fold_minus or chrec_fold_plus.
2006-04-02 Sebastian Pop <pop@cri.ensmp.fr>
* tree-data-ref.c (compute_all_dependences): Use a pointer to * tree-data-ref.c (compute_all_dependences): Use a pointer to
the dependence_relations vector. the dependence_relations vector.
(compute_data_dependences_for_loop): Adjust call to (compute_data_dependences_for_loop): Adjust call to
......
...@@ -63,7 +63,8 @@ chrec_fold_poly_cst (enum tree_code code, ...@@ -63,7 +63,8 @@ chrec_fold_poly_cst (enum tree_code code,
gcc_assert (cst); gcc_assert (cst);
gcc_assert (TREE_CODE (poly) == POLYNOMIAL_CHREC); gcc_assert (TREE_CODE (poly) == POLYNOMIAL_CHREC);
gcc_assert (!is_not_constant_evolution (cst)); gcc_assert (!is_not_constant_evolution (cst));
gcc_assert (type == chrec_type (poly));
switch (code) switch (code)
{ {
case PLUS_EXPR: case PLUS_EXPR:
...@@ -103,6 +104,8 @@ chrec_fold_plus_poly_poly (enum tree_code code, ...@@ -103,6 +104,8 @@ chrec_fold_plus_poly_poly (enum tree_code code,
gcc_assert (poly1); gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC); gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC); gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
gcc_assert (chrec_type (poly0) == chrec_type (poly1));
gcc_assert (type == chrec_type (poly0));
/* /*
{a, +, b}_1 + {c, +, d}_2 -> {{a, +, b}_1 + c, +, d}_2, {a, +, b}_1 + {c, +, d}_2 -> {{a, +, b}_1 + c, +, d}_2,
...@@ -177,6 +180,8 @@ chrec_fold_multiply_poly_poly (tree type, ...@@ -177,6 +180,8 @@ chrec_fold_multiply_poly_poly (tree type,
gcc_assert (poly1); gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC); gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC); gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
gcc_assert (chrec_type (poly0) == chrec_type (poly1));
gcc_assert (type == chrec_type (poly0));
/* {a, +, b}_1 * {c, +, d}_2 -> {c*{a, +, b}_1, +, d}_2, /* {a, +, b}_1 * {c, +, d}_2 -> {c*{a, +, b}_1, +, d}_2,
{a, +, b}_2 * {c, +, d}_1 -> {a*{c, +, d}_1, +, b}_2, {a, +, b}_2 * {c, +, d}_1 -> {a*{c, +, d}_1, +, b}_2,
...@@ -246,10 +251,8 @@ chrec_fold_automatically_generated_operands (tree op0, ...@@ -246,10 +251,8 @@ chrec_fold_automatically_generated_operands (tree op0,
/* Fold the addition of two chrecs. */ /* Fold the addition of two chrecs. */
static tree static tree
chrec_fold_plus_1 (enum tree_code code, chrec_fold_plus_1 (enum tree_code code, tree type,
tree type, tree op0, tree op1)
tree op0,
tree op1)
{ {
if (automatically_generated_chrec_p (op0) if (automatically_generated_chrec_p (op0)
|| automatically_generated_chrec_p (op1)) || automatically_generated_chrec_p (op1))
...@@ -319,6 +322,10 @@ chrec_fold_plus (tree type, ...@@ -319,6 +322,10 @@ chrec_fold_plus (tree type,
tree op0, tree op0,
tree op1) tree op1)
{ {
if (automatically_generated_chrec_p (op0)
|| automatically_generated_chrec_p (op1))
return chrec_fold_automatically_generated_operands (op0, op1);
if (integer_zerop (op0)) if (integer_zerop (op0))
return op1; return op1;
if (integer_zerop (op1)) if (integer_zerop (op1))
...@@ -334,6 +341,10 @@ chrec_fold_minus (tree type, ...@@ -334,6 +341,10 @@ chrec_fold_minus (tree type,
tree op0, tree op0,
tree op1) tree op1)
{ {
if (automatically_generated_chrec_p (op0)
|| automatically_generated_chrec_p (op1))
return chrec_fold_automatically_generated_operands (op0, op1);
if (integer_zerop (op1)) if (integer_zerop (op1))
return op0; return op0;
...@@ -583,7 +594,9 @@ chrec_replace_initial_condition (tree chrec, ...@@ -583,7 +594,9 @@ chrec_replace_initial_condition (tree chrec,
{ {
if (automatically_generated_chrec_p (chrec)) if (automatically_generated_chrec_p (chrec))
return chrec; return chrec;
gcc_assert (chrec_type (chrec) == chrec_type (init_cond));
switch (TREE_CODE (chrec)) switch (TREE_CODE (chrec))
{ {
case POLYNOMIAL_CHREC: case POLYNOMIAL_CHREC:
...@@ -729,6 +742,8 @@ reset_evolution_in_loop (unsigned loop_num, ...@@ -729,6 +742,8 @@ reset_evolution_in_loop (unsigned loop_num,
tree chrec, tree chrec,
tree new_evol) tree new_evol)
{ {
gcc_assert (chrec_type (chrec) == chrec_type (new_evol));
if (TREE_CODE (chrec) == POLYNOMIAL_CHREC if (TREE_CODE (chrec) == POLYNOMIAL_CHREC
&& CHREC_VARIABLE (chrec) > loop_num) && CHREC_VARIABLE (chrec) > loop_num)
{ {
...@@ -1241,17 +1256,6 @@ chrec_convert_aggressive (tree type, tree chrec) ...@@ -1241,17 +1256,6 @@ chrec_convert_aggressive (tree type, tree chrec)
return build_polynomial_chrec (CHREC_VARIABLE (chrec), lc, rc); return build_polynomial_chrec (CHREC_VARIABLE (chrec), lc, rc);
} }
/* Returns the type of the chrec. */
tree
chrec_type (tree chrec)
{
if (automatically_generated_chrec_p (chrec))
return NULL_TREE;
return TREE_TYPE (chrec);
}
/* Returns true when CHREC0 == CHREC1. */ /* Returns true when CHREC0 == CHREC1. */
bool bool
...@@ -1269,8 +1273,8 @@ eq_evolutions_p (tree chrec0, ...@@ -1269,8 +1273,8 @@ eq_evolutions_p (tree chrec0,
switch (TREE_CODE (chrec0)) switch (TREE_CODE (chrec0))
{ {
case INTEGER_CST: case INTEGER_CST:
return integer_zerop (fold (build2 (MINUS_EXPR, TREE_TYPE (chrec0), return operand_equal_p (chrec0, chrec1, 0);
chrec0, chrec1)));
case POLYNOMIAL_CHREC: case POLYNOMIAL_CHREC:
return (CHREC_VARIABLE (chrec0) == CHREC_VARIABLE (chrec1) return (CHREC_VARIABLE (chrec0) == CHREC_VARIABLE (chrec1)
&& eq_evolutions_p (CHREC_LEFT (chrec0), CHREC_LEFT (chrec1)) && eq_evolutions_p (CHREC_LEFT (chrec0), CHREC_LEFT (chrec1))
......
...@@ -69,7 +69,6 @@ extern tree chrec_fold_minus (tree, tree, tree); ...@@ -69,7 +69,6 @@ extern tree chrec_fold_minus (tree, tree, tree);
extern tree chrec_fold_multiply (tree, tree, tree); extern tree chrec_fold_multiply (tree, tree, tree);
extern tree chrec_convert (tree, tree, tree); extern tree chrec_convert (tree, tree, tree);
extern tree chrec_convert_aggressive (tree, tree); extern tree chrec_convert_aggressive (tree, tree);
extern tree chrec_type (tree);
/* Operations. */ /* Operations. */
extern tree chrec_apply (unsigned, tree, tree); extern tree chrec_apply (unsigned, tree, tree);
...@@ -106,6 +105,8 @@ build_polynomial_chrec (unsigned loop_num, ...@@ -106,6 +105,8 @@ build_polynomial_chrec (unsigned loop_num,
|| right == chrec_dont_know) || right == chrec_dont_know)
return chrec_dont_know; return chrec_dont_know;
gcc_assert (TREE_TYPE (left) == TREE_TYPE (right));
return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left), return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left),
build_int_cst (NULL_TREE, loop_num), left, right); build_int_cst (NULL_TREE, loop_num), left, right);
} }
...@@ -208,4 +209,16 @@ no_evolution_in_loop_p (tree chrec, unsigned loop_num, bool *res) ...@@ -208,4 +209,16 @@ no_evolution_in_loop_p (tree chrec, unsigned loop_num, bool *res)
return true; return true;
} }
/* Returns the type of the chrec. */
static inline tree
chrec_type (tree chrec)
{
if (automatically_generated_chrec_p (chrec))
return NULL_TREE;
return TREE_TYPE (chrec);
}
#endif /* GCC_TREE_CHREC_H */ #endif /* GCC_TREE_CHREC_H */
...@@ -1930,8 +1930,8 @@ create_data_ref (tree memref, tree stmt, bool is_read) ...@@ -1930,8 +1930,8 @@ create_data_ref (tree memref, tree stmt, bool is_read)
constant, type_size); constant, type_size);
} }
else else
DR_INIT (dr) = init_cond = ssize_int (0);; DR_INIT (dr) = init_cond = ssize_int (0);
if (invariant) if (invariant)
DR_OFFSET (dr) = invariant; DR_OFFSET (dr) = invariant;
else else
...@@ -1957,6 +1957,8 @@ create_data_ref (tree memref, tree stmt, bool is_read) ...@@ -1957,6 +1957,8 @@ create_data_ref (tree memref, tree stmt, bool is_read)
new_step = size_binop (TRUNC_DIV_EXPR, new_step = size_binop (TRUNC_DIV_EXPR,
fold_convert (ssizetype, step), type_size); fold_convert (ssizetype, step), type_size);
init_cond = chrec_convert (chrec_type (access_fn), init_cond, stmt);
new_step = chrec_convert (chrec_type (access_fn), new_step, stmt);
access_fn = chrec_replace_initial_condition (access_fn, init_cond); access_fn = chrec_replace_initial_condition (access_fn, init_cond);
access_fn = reset_evolution_in_loop (loop->num, access_fn, new_step); access_fn = reset_evolution_in_loop (loop->num, access_fn, new_step);
...@@ -2011,14 +2013,10 @@ all_chrecs_equal_p (tree chrec) ...@@ -2011,14 +2013,10 @@ all_chrecs_equal_p (tree chrec)
int j; int j;
for (j = 0; j < TREE_VEC_LENGTH (chrec) - 1; j++) for (j = 0; j < TREE_VEC_LENGTH (chrec) - 1; j++)
{ if (!eq_evolutions_p (TREE_VEC_ELT (chrec, j),
tree chrec_j = TREE_VEC_ELT (chrec, j); TREE_VEC_ELT (chrec, j + 1)))
tree chrec_j_1 = TREE_VEC_ELT (chrec, j + 1); return false;
if (!integer_zerop
(chrec_fold_minus
(integer_type_node, chrec_j, chrec_j_1)))
return false;
}
return true; return true;
} }
...@@ -2063,6 +2061,10 @@ compute_subscript_distance (struct data_dependence_relation *ddr) ...@@ -2063,6 +2061,10 @@ compute_subscript_distance (struct data_dependence_relation *ddr)
conflicts_b = TREE_VEC_ELT (conflicts_b, 0); conflicts_b = TREE_VEC_ELT (conflicts_b, 0);
} }
conflicts_b = chrec_convert (integer_type_node, conflicts_b,
NULL_TREE);
conflicts_a = chrec_convert (integer_type_node, conflicts_a,
NULL_TREE);
difference = chrec_fold_minus difference = chrec_fold_minus
(integer_type_node, conflicts_b, conflicts_a); (integer_type_node, conflicts_b, conflicts_a);
...@@ -2250,6 +2252,8 @@ analyze_ziv_subscript (tree chrec_a, ...@@ -2250,6 +2252,8 @@ analyze_ziv_subscript (tree chrec_a,
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "(analyze_ziv_subscript \n"); fprintf (dump_file, "(analyze_ziv_subscript \n");
chrec_a = chrec_convert (integer_type_node, chrec_a, NULL_TREE);
chrec_b = chrec_convert (integer_type_node, chrec_b, NULL_TREE);
difference = chrec_fold_minus (integer_type_node, chrec_a, chrec_b); difference = chrec_fold_minus (integer_type_node, chrec_a, chrec_b);
switch (TREE_CODE (difference)) switch (TREE_CODE (difference))
...@@ -2323,7 +2327,11 @@ analyze_siv_subscript_cst_affine (tree chrec_a, ...@@ -2323,7 +2327,11 @@ analyze_siv_subscript_cst_affine (tree chrec_a,
tree *last_conflicts) tree *last_conflicts)
{ {
bool value0, value1, value2; bool value0, value1, value2;
tree difference = chrec_fold_minus tree difference;
chrec_a = chrec_convert (integer_type_node, chrec_a, NULL_TREE);
chrec_b = chrec_convert (integer_type_node, chrec_b, NULL_TREE);
difference = chrec_fold_minus
(integer_type_node, CHREC_LEFT (chrec_b), chrec_a); (integer_type_node, CHREC_LEFT (chrec_b), chrec_a);
if (!chrec_is_positive (initial_condition (difference), &value0)) if (!chrec_is_positive (initial_condition (difference), &value0))
...@@ -2641,32 +2649,52 @@ compute_overlap_steps_for_affine_1_2 (tree chrec_a, tree chrec_b, ...@@ -2641,32 +2649,52 @@ compute_overlap_steps_for_affine_1_2 (tree chrec_a, tree chrec_b,
*overlaps_b = integer_zero_node; *overlaps_b = integer_zero_node;
if (xz_p) if (xz_p)
{ {
TREE_VEC_ELT (*overlaps_a, 0) = tree t0 = chrec_convert (integer_type_node,
chrec_fold_plus (integer_type_node, TREE_VEC_ELT (*overlaps_a, 0), TREE_VEC_ELT (*overlaps_a, 0), NULL_TREE);
overlaps_a_xz); tree t1 = chrec_convert (integer_type_node, overlaps_a_xz,
*overlaps_b = NULL_TREE);
chrec_fold_plus (integer_type_node, *overlaps_b, overlaps_b_xz); tree t2 = chrec_convert (integer_type_node, *overlaps_b,
NULL_TREE);
tree t3 = chrec_convert (integer_type_node, overlaps_b_xz,
NULL_TREE);
TREE_VEC_ELT (*overlaps_a, 0) = chrec_fold_plus (integer_type_node,
t0, t1);
*overlaps_b = chrec_fold_plus (integer_type_node, t2, t3);
*last_conflicts = last_conflicts_xz; *last_conflicts = last_conflicts_xz;
} }
if (yz_p) if (yz_p)
{ {
TREE_VEC_ELT (*overlaps_a, 1) = tree t0 = chrec_convert (integer_type_node,
chrec_fold_plus (integer_type_node, TREE_VEC_ELT (*overlaps_a, 1), TREE_VEC_ELT (*overlaps_a, 1), NULL_TREE);
overlaps_a_yz); tree t1 = chrec_convert (integer_type_node, overlaps_a_yz, NULL_TREE);
*overlaps_b = tree t2 = chrec_convert (integer_type_node, *overlaps_b, NULL_TREE);
chrec_fold_plus (integer_type_node, *overlaps_b, overlaps_b_yz); tree t3 = chrec_convert (integer_type_node, overlaps_b_yz, NULL_TREE);
TREE_VEC_ELT (*overlaps_a, 1) = chrec_fold_plus (integer_type_node,
t0, t1);
*overlaps_b = chrec_fold_plus (integer_type_node, t2, t3);
*last_conflicts = last_conflicts_yz; *last_conflicts = last_conflicts_yz;
} }
if (xyz_p) if (xyz_p)
{ {
TREE_VEC_ELT (*overlaps_a, 0) = tree t0 = chrec_convert (integer_type_node,
chrec_fold_plus (integer_type_node, TREE_VEC_ELT (*overlaps_a, 0), TREE_VEC_ELT (*overlaps_a, 0), NULL_TREE);
overlaps_a_xyz); tree t1 = chrec_convert (integer_type_node, overlaps_a_xyz,
TREE_VEC_ELT (*overlaps_a, 1) = NULL_TREE);
chrec_fold_plus (integer_type_node, TREE_VEC_ELT (*overlaps_a, 1), tree t2 = chrec_convert (integer_type_node,
overlaps_a_xyz); TREE_VEC_ELT (*overlaps_a, 1), NULL_TREE);
*overlaps_b = tree t3 = chrec_convert (integer_type_node, overlaps_a_xyz,
chrec_fold_plus (integer_type_node, *overlaps_b, overlaps_b_xyz); NULL_TREE);
tree t4 = chrec_convert (integer_type_node, *overlaps_b, NULL_TREE);
tree t5 = chrec_convert (integer_type_node, overlaps_b_xyz,
NULL_TREE);
TREE_VEC_ELT (*overlaps_a, 0) = chrec_fold_plus (integer_type_node,
t0, t1);
TREE_VEC_ELT (*overlaps_a, 1) = chrec_fold_plus (integer_type_node,
t2, t3);
*overlaps_b = chrec_fold_plus (integer_type_node, t4, t5);
*last_conflicts = last_conflicts_xyz; *last_conflicts = last_conflicts_xyz;
} }
} }
...@@ -2694,12 +2722,11 @@ analyze_subscript_affine_affine (tree chrec_a, ...@@ -2694,12 +2722,11 @@ analyze_subscript_affine_affine (tree chrec_a,
int init_a, init_b, gamma, gcd_alpha_beta; int init_a, init_b, gamma, gcd_alpha_beta;
int tau1, tau2; int tau1, tau2;
lambda_matrix A, U, S; lambda_matrix A, U, S;
tree difference = chrec_fold_minus (integer_type_node, chrec_a, chrec_b);
if (integer_zerop (difference)) if (eq_evolutions_p (chrec_a, chrec_b))
{ {
/* The difference is equal to zero: the accessed index /* The accessed index overlaps for each iteration in the
overlaps for each iteration in the loop. */ loop. */
*overlaps_a = integer_zero_node; *overlaps_a = integer_zero_node;
*overlaps_b = integer_zero_node; *overlaps_b = integer_zero_node;
*last_conflicts = chrec_dont_know; *last_conflicts = chrec_dont_know;
...@@ -2719,7 +2746,6 @@ analyze_subscript_affine_affine (tree chrec_a, ...@@ -2719,7 +2746,6 @@ analyze_subscript_affine_affine (tree chrec_a,
there is no dependence. This function outputs a description of there is no dependence. This function outputs a description of
the iterations that hold the intersections. */ the iterations that hold the intersections. */
nb_vars_a = nb_vars_in_chrec (chrec_a); nb_vars_a = nb_vars_in_chrec (chrec_a);
nb_vars_b = nb_vars_in_chrec (chrec_b); nb_vars_b = nb_vars_in_chrec (chrec_b);
...@@ -3177,10 +3203,12 @@ analyze_miv_subscript (tree chrec_a, ...@@ -3177,10 +3203,12 @@ analyze_miv_subscript (tree chrec_a,
dependence_stats.num_miv++; dependence_stats.num_miv++;
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "(analyze_miv_subscript \n"); fprintf (dump_file, "(analyze_miv_subscript \n");
chrec_a = chrec_convert (integer_type_node, chrec_a, NULL_TREE);
chrec_b = chrec_convert (integer_type_node, chrec_b, NULL_TREE);
difference = chrec_fold_minus (integer_type_node, chrec_a, chrec_b); difference = chrec_fold_minus (integer_type_node, chrec_a, chrec_b);
if (chrec_zerop (difference)) if (eq_evolutions_p (chrec_a, chrec_b))
{ {
/* Access functions are the same: all the elements are accessed /* Access functions are the same: all the elements are accessed
in the same order. */ in the same order. */
...@@ -3502,15 +3530,9 @@ same_access_functions (struct data_dependence_relation *ddr) ...@@ -3502,15 +3530,9 @@ same_access_functions (struct data_dependence_relation *ddr)
unsigned i; unsigned i;
for (i = 0; i < DDR_NUM_SUBSCRIPTS (ddr); i++) for (i = 0; i < DDR_NUM_SUBSCRIPTS (ddr); i++)
{ if (!eq_evolutions_p (DR_ACCESS_FN (DDR_A (ddr), i),
tree access_fun_a = DR_ACCESS_FN (DDR_A (ddr), i); DR_ACCESS_FN (DDR_B (ddr), i)))
tree access_fun_b = DR_ACCESS_FN (DDR_B (ddr), i); return false;
tree difference = chrec_fold_minus (integer_type_node, access_fun_a,
access_fun_b);
if (TREE_CODE (difference) != INTEGER_CST
|| !integer_zerop (difference))
return false;
}
return true; return true;
} }
......
...@@ -659,18 +659,19 @@ get_scalar_evolution (tree scalar) ...@@ -659,18 +659,19 @@ get_scalar_evolution (tree scalar)
part for this loop. */ part for this loop. */
static tree static tree
add_to_evolution_1 (unsigned loop_nb, add_to_evolution_1 (unsigned loop_nb, tree chrec_before, tree to_add,
tree chrec_before, tree at_stmt)
tree to_add)
{ {
tree type, left, right;
switch (TREE_CODE (chrec_before)) switch (TREE_CODE (chrec_before))
{ {
case POLYNOMIAL_CHREC: case POLYNOMIAL_CHREC:
if (CHREC_VARIABLE (chrec_before) <= loop_nb) if (CHREC_VARIABLE (chrec_before) <= loop_nb)
{ {
unsigned var; unsigned var;
tree left, right;
tree type = chrec_type (chrec_before); type = chrec_type (chrec_before);
/* When there is no evolution part in this loop, build it. */ /* When there is no evolution part in this loop, build it. */
if (CHREC_VARIABLE (chrec_before) < loop_nb) if (CHREC_VARIABLE (chrec_before) < loop_nb)
...@@ -688,21 +689,30 @@ add_to_evolution_1 (unsigned loop_nb, ...@@ -688,21 +689,30 @@ add_to_evolution_1 (unsigned loop_nb,
right = CHREC_RIGHT (chrec_before); right = CHREC_RIGHT (chrec_before);
} }
return build_polynomial_chrec to_add = chrec_convert (type, to_add, at_stmt);
(var, left, chrec_fold_plus (type, right, to_add)); right = chrec_convert (type, right, at_stmt);
right = chrec_fold_plus (type, right, to_add);
return build_polynomial_chrec (var, left, right);
} }
else else
/* Search the evolution in LOOP_NB. */ {
return build_polynomial_chrec /* Search the evolution in LOOP_NB. */
(CHREC_VARIABLE (chrec_before), left = add_to_evolution_1 (loop_nb, CHREC_LEFT (chrec_before),
add_to_evolution_1 (loop_nb, CHREC_LEFT (chrec_before), to_add), to_add, at_stmt);
CHREC_RIGHT (chrec_before)); right = CHREC_RIGHT (chrec_before);
right = chrec_convert (chrec_type (left), right, at_stmt);
return build_polynomial_chrec (CHREC_VARIABLE (chrec_before),
left, right);
}
default: default:
/* These nodes do not depend on a loop. */ /* These nodes do not depend on a loop. */
if (chrec_before == chrec_dont_know) if (chrec_before == chrec_dont_know)
return chrec_dont_know; return chrec_dont_know;
return build_polynomial_chrec (loop_nb, chrec_before, to_add);
left = chrec_before;
right = chrec_convert (chrec_type (left), to_add, at_stmt);
return build_polynomial_chrec (loop_nb, left, right);
} }
} }
...@@ -841,10 +851,8 @@ add_to_evolution_1 (unsigned loop_nb, ...@@ -841,10 +851,8 @@ add_to_evolution_1 (unsigned loop_nb,
*/ */
static tree static tree
add_to_evolution (unsigned loop_nb, add_to_evolution (unsigned loop_nb, tree chrec_before, enum tree_code code,
tree chrec_before, tree to_add, tree at_stmt)
enum tree_code code,
tree to_add)
{ {
tree type = chrec_type (to_add); tree type = chrec_type (to_add);
tree res = NULL_TREE; tree res = NULL_TREE;
...@@ -874,7 +882,7 @@ add_to_evolution (unsigned loop_nb, ...@@ -874,7 +882,7 @@ add_to_evolution (unsigned loop_nb,
? build_real (type, dconstm1) ? build_real (type, dconstm1)
: build_int_cst_type (type, -1)); : build_int_cst_type (type, -1));
res = add_to_evolution_1 (loop_nb, chrec_before, to_add); res = add_to_evolution_1 (loop_nb, chrec_before, to_add, at_stmt);
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
...@@ -1094,7 +1102,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs, ...@@ -1094,7 +1102,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
*evolution_of_loop = add_to_evolution *evolution_of_loop = add_to_evolution
(loop->num, (loop->num,
chrec_convert (type_rhs, evol, at_stmt), chrec_convert (type_rhs, evol, at_stmt),
PLUS_EXPR, rhs1); PLUS_EXPR, rhs1, at_stmt);
else if (res == t_false) else if (res == t_false)
{ {
...@@ -1106,7 +1114,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs, ...@@ -1106,7 +1114,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
*evolution_of_loop = add_to_evolution *evolution_of_loop = add_to_evolution
(loop->num, (loop->num,
chrec_convert (type_rhs, *evolution_of_loop, at_stmt), chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
PLUS_EXPR, rhs0); PLUS_EXPR, rhs0, at_stmt);
else if (res == t_dont_know) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
...@@ -1127,7 +1135,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs, ...@@ -1127,7 +1135,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
*evolution_of_loop = add_to_evolution *evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop, (loop->num, chrec_convert (type_rhs, *evolution_of_loop,
at_stmt), at_stmt),
PLUS_EXPR, rhs1); PLUS_EXPR, rhs1, at_stmt);
else if (res == t_dont_know) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
...@@ -1145,7 +1153,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs, ...@@ -1145,7 +1153,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
*evolution_of_loop = add_to_evolution *evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop, (loop->num, chrec_convert (type_rhs, *evolution_of_loop,
at_stmt), at_stmt),
PLUS_EXPR, rhs0); PLUS_EXPR, rhs0, at_stmt);
else if (res == t_dont_know) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
...@@ -1175,7 +1183,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs, ...@@ -1175,7 +1183,7 @@ follow_ssa_edge_in_rhs (struct loop *loop, tree at_stmt, tree rhs,
if (res == t_true) if (res == t_true)
*evolution_of_loop = add_to_evolution *evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop, at_stmt), (loop->num, chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
MINUS_EXPR, rhs1); MINUS_EXPR, rhs1, at_stmt);
else if (res == t_dont_know) else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know; *evolution_of_loop = chrec_dont_know;
...@@ -2043,7 +2051,10 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache ...@@ -2043,7 +2051,10 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
if (CHREC_LEFT (chrec) != op0 if (CHREC_LEFT (chrec) != op0
|| CHREC_RIGHT (chrec) != op1) || CHREC_RIGHT (chrec) != op1)
chrec = build_polynomial_chrec (CHREC_VARIABLE (chrec), op0, op1); {
op1 = chrec_convert (chrec_type (op0), op1, NULL_TREE);
chrec = build_polynomial_chrec (CHREC_VARIABLE (chrec), op0, op1);
}
return chrec; return chrec;
case PLUS_EXPR: case PLUS_EXPR:
......
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