This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix PR26859
On 3/29/06, Sebastian Pop <sebpop@gmail.com> wrote:
> I'll try to include your assert patch and bootstrap with it.
>
Here is the patch that bootstrapped on amd64-linux, I'll commit it
after it passes testing.
Sebastian
2006-03-30 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): Use eq_evolutions_p.
Index: tree-scalar-evolution.c
===================================================================
*** tree-scalar-evolution.c (revision 112501)
--- tree-scalar-evolution.c (working copy)
*************** get_scalar_evolution (tree scalar)
*** 659,676 ****
part for this loop. */
static tree
! add_to_evolution_1 (unsigned loop_nb,
! tree chrec_before,
! tree to_add)
{
switch (TREE_CODE (chrec_before))
{
case POLYNOMIAL_CHREC:
if (CHREC_VARIABLE (chrec_before) <= loop_nb)
{
unsigned var;
! tree left, right;
! tree type = chrec_type (chrec_before);
/* When there is no evolution part in this loop, build it. */
if (CHREC_VARIABLE (chrec_before) < loop_nb)
--- 659,677 ----
part for this loop. */
static tree
! add_to_evolution_1 (unsigned loop_nb, tree chrec_before, tree to_add,
! tree at_stmt)
{
+ tree type, left, right;
+
switch (TREE_CODE (chrec_before))
{
case POLYNOMIAL_CHREC:
if (CHREC_VARIABLE (chrec_before) <= loop_nb)
{
unsigned var;
!
! type = chrec_type (chrec_before);
/* When there is no evolution part in this loop, build it. */
if (CHREC_VARIABLE (chrec_before) < loop_nb)
*************** add_to_evolution_1 (unsigned loop_nb,
*** 688,708 ****
right = CHREC_RIGHT (chrec_before);
}
! return build_polynomial_chrec
! (var, left, chrec_fold_plus (type, right, to_add));
}
else
! /* Search the evolution in LOOP_NB. */
! return build_polynomial_chrec
! (CHREC_VARIABLE (chrec_before),
! add_to_evolution_1 (loop_nb, CHREC_LEFT (chrec_before), to_add),
! CHREC_RIGHT (chrec_before));
default:
/* These nodes do not depend on a loop. */
if (chrec_before == chrec_dont_know)
return chrec_dont_know;
! return build_polynomial_chrec (loop_nb, chrec_before, to_add);
}
}
--- 689,718 ----
right = CHREC_RIGHT (chrec_before);
}
! to_add = chrec_convert (type, to_add, at_stmt);
! right = chrec_convert (type, right, at_stmt);
! right = chrec_fold_plus (type, right, to_add);
! return build_polynomial_chrec (var, left, right);
}
else
! {
! /* Search the evolution in LOOP_NB. */
! left = add_to_evolution_1 (loop_nb, CHREC_LEFT (chrec_before),
! to_add, at_stmt);
! 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:
/* These nodes do not depend on a loop. */
if (chrec_before == chrec_dont_know)
return chrec_dont_know;
!
! left = chrec_before;
! right = chrec_convert (chrec_type (left), to_add, at_stmt);
! return build_polynomial_chrec (loop_nb, left, right);
}
}
*************** add_to_evolution_1 (unsigned loop_nb,
*** 841,850 ****
*/
static tree
! add_to_evolution (unsigned loop_nb,
! tree chrec_before,
! enum tree_code code,
! tree to_add)
{
tree type = chrec_type (to_add);
tree res = NULL_TREE;
--- 851,858 ----
*/
static tree
! add_to_evolution (unsigned loop_nb, tree chrec_before, enum tree_code code,
! tree to_add, tree at_stmt)
{
tree type = chrec_type (to_add);
tree res = NULL_TREE;
*************** add_to_evolution (unsigned loop_nb,
*** 874,880 ****
? build_real (type, dconstm1)
: build_int_cst_type (type, -1));
! res = add_to_evolution_1 (loop_nb, chrec_before, to_add);
if (dump_file && (dump_flags & TDF_DETAILS))
{
--- 882,888 ----
? build_real (type, dconstm1)
: build_int_cst_type (type, -1));
! res = add_to_evolution_1 (loop_nb, chrec_before, to_add, at_stmt);
if (dump_file && (dump_flags & TDF_DETAILS))
{
*************** follow_ssa_edge_in_rhs (struct loop *loo
*** 1094,1100 ****
*evolution_of_loop = add_to_evolution
(loop->num,
chrec_convert (type_rhs, evol, at_stmt),
! PLUS_EXPR, rhs1);
else if (res == t_false)
{
--- 1102,1108 ----
*evolution_of_loop = add_to_evolution
(loop->num,
chrec_convert (type_rhs, evol, at_stmt),
! PLUS_EXPR, rhs1, at_stmt);
else if (res == t_false)
{
*************** follow_ssa_edge_in_rhs (struct loop *loo
*** 1106,1112 ****
*evolution_of_loop = add_to_evolution
(loop->num,
chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
! PLUS_EXPR, rhs0);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
--- 1114,1120 ----
*evolution_of_loop = add_to_evolution
(loop->num,
chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
! PLUS_EXPR, rhs0, at_stmt);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
*************** follow_ssa_edge_in_rhs (struct loop *loo
*** 1127,1133 ****
*evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop,
at_stmt),
! PLUS_EXPR, rhs1);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
--- 1135,1141 ----
*evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop,
at_stmt),
! PLUS_EXPR, rhs1, at_stmt);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
*************** follow_ssa_edge_in_rhs (struct loop *loo
*** 1145,1151 ****
*evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop,
at_stmt),
! PLUS_EXPR, rhs0);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
--- 1153,1159 ----
*evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop,
at_stmt),
! PLUS_EXPR, rhs0, at_stmt);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
*************** follow_ssa_edge_in_rhs (struct loop *loo
*** 1175,1181 ****
if (res == t_true)
*evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
! MINUS_EXPR, rhs1);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
--- 1183,1189 ----
if (res == t_true)
*evolution_of_loop = add_to_evolution
(loop->num, chrec_convert (type_rhs, *evolution_of_loop, at_stmt),
! MINUS_EXPR, rhs1, at_stmt);
else if (res == t_dont_know)
*evolution_of_loop = chrec_dont_know;
*************** instantiate_parameters_1 (struct loop *l
*** 2043,2049 ****
if (CHREC_LEFT (chrec) != op0
|| CHREC_RIGHT (chrec) != op1)
! chrec = build_polynomial_chrec (CHREC_VARIABLE (chrec), op0, op1);
return chrec;
case PLUS_EXPR:
--- 2051,2060 ----
if (CHREC_LEFT (chrec) != op0
|| CHREC_RIGHT (chrec) != op1)
! {
! op1 = chrec_convert (chrec_type (op0), op1, NULL_TREE);
! chrec = build_polynomial_chrec (CHREC_VARIABLE (chrec), op0, op1);
! }
return chrec;
case PLUS_EXPR:
Index: tree-chrec.c
===================================================================
*** tree-chrec.c (revision 112501)
--- tree-chrec.c (working copy)
*************** chrec_fold_poly_cst (enum tree_code code
*** 63,69 ****
gcc_assert (cst);
gcc_assert (TREE_CODE (poly) == POLYNOMIAL_CHREC);
gcc_assert (!is_not_constant_evolution (cst));
!
switch (code)
{
case PLUS_EXPR:
--- 63,70 ----
gcc_assert (cst);
gcc_assert (TREE_CODE (poly) == POLYNOMIAL_CHREC);
gcc_assert (!is_not_constant_evolution (cst));
! gcc_assert (type == chrec_type (poly));
!
switch (code)
{
case PLUS_EXPR:
*************** chrec_fold_plus_poly_poly (enum tree_cod
*** 103,108 ****
--- 104,111 ----
gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == 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,
*************** chrec_fold_multiply_poly_poly (tree type
*** 177,182 ****
--- 180,187 ----
gcc_assert (poly1);
gcc_assert (TREE_CODE (poly0) == 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}_2 * {c, +, d}_1 -> {a*{c, +, d}_1, +, b}_2,
*************** chrec_fold_automatically_generated_opera
*** 246,255 ****
/* Fold the addition of two chrecs. */
static tree
! chrec_fold_plus_1 (enum tree_code code,
! tree type,
! tree op0,
! tree op1)
{
if (automatically_generated_chrec_p (op0)
|| automatically_generated_chrec_p (op1))
--- 251,258 ----
/* Fold the addition of two chrecs. */
static tree
! chrec_fold_plus_1 (enum tree_code code, tree type,
! tree op0, tree op1)
{
if (automatically_generated_chrec_p (op0)
|| automatically_generated_chrec_p (op1))
*************** chrec_replace_initial_condition (tree ch
*** 583,589 ****
{
if (automatically_generated_chrec_p (chrec))
return chrec;
!
switch (TREE_CODE (chrec))
{
case POLYNOMIAL_CHREC:
--- 586,594 ----
{
if (automatically_generated_chrec_p (chrec))
return chrec;
!
! gcc_assert (chrec_type (chrec) == chrec_type (init_cond));
!
switch (TREE_CODE (chrec))
{
case POLYNOMIAL_CHREC:
*************** reset_evolution_in_loop (unsigned loop_n
*** 729,734 ****
--- 734,741 ----
tree chrec,
tree new_evol)
{
+ gcc_assert (chrec_type (chrec) == chrec_type (new_evol));
+
if (TREE_CODE (chrec) == POLYNOMIAL_CHREC
&& CHREC_VARIABLE (chrec) > loop_num)
{
*************** chrec_convert_aggressive (tree type, tre
*** 1241,1257 ****
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. */
bool
--- 1248,1253 ----
*************** eq_evolutions_p (tree chrec0,
*** 1269,1276 ****
switch (TREE_CODE (chrec0))
{
case INTEGER_CST:
! return integer_zerop (fold (build2 (MINUS_EXPR, TREE_TYPE (chrec0),
! chrec0, chrec1)));
case POLYNOMIAL_CHREC:
return (CHREC_VARIABLE (chrec0) == CHREC_VARIABLE (chrec1)
&& eq_evolutions_p (CHREC_LEFT (chrec0), CHREC_LEFT (chrec1))
--- 1265,1272 ----
switch (TREE_CODE (chrec0))
{
case INTEGER_CST:
! return operand_equal_p (chrec0, chrec1, 0);
!
case POLYNOMIAL_CHREC:
return (CHREC_VARIABLE (chrec0) == CHREC_VARIABLE (chrec1)
&& eq_evolutions_p (CHREC_LEFT (chrec0), CHREC_LEFT (chrec1))
Index: tree-chrec.h
===================================================================
*** tree-chrec.h (revision 112501)
--- tree-chrec.h (working copy)
*************** extern tree chrec_fold_minus (tree, tree
*** 69,75 ****
extern tree chrec_fold_multiply (tree, tree, tree);
extern tree chrec_convert (tree, tree, tree);
extern tree chrec_convert_aggressive (tree, tree);
- extern tree chrec_type (tree);
/* Operations. */
extern tree chrec_apply (unsigned, tree, tree);
--- 69,74 ----
*************** build_polynomial_chrec (unsigned loop_nu
*** 106,111 ****
--- 105,112 ----
|| right == chrec_dont_know)
return chrec_dont_know;
+ gcc_assert (TREE_TYPE (left) == TREE_TYPE (right));
+
return build3 (POLYNOMIAL_CHREC, TREE_TYPE (left),
build_int_cst (NULL_TREE, loop_num), left, right);
}
*************** no_evolution_in_loop_p (tree chrec, unsi
*** 208,211 ****
--- 209,224 ----
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 */
Index: tree-data-ref.c
===================================================================
*** tree-data-ref.c (revision 112507)
--- tree-data-ref.c (working copy)
*************** create_data_ref (tree memref, tree stmt,
*** 1930,1937 ****
constant, type_size);
}
else
! DR_INIT (dr) = init_cond = ssize_int (0);;
!
if (invariant)
DR_OFFSET (dr) = invariant;
else
--- 1930,1937 ----
constant, type_size);
}
else
! DR_INIT (dr) = init_cond = ssize_int (0);
!
if (invariant)
DR_OFFSET (dr) = invariant;
else
*************** create_data_ref (tree memref, tree stmt,
*** 1957,1962 ****
--- 1957,1964 ----
new_step = size_binop (TRUNC_DIV_EXPR,
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 = reset_evolution_in_loop (loop->num, access_fn, new_step);
*************** same_access_functions (struct data_depen
*** 3502,3516 ****
unsigned i;
for (i = 0; i < DDR_NUM_SUBSCRIPTS (ddr); i++)
! {
! tree access_fun_a = DR_ACCESS_FN (DDR_A (ddr), i);
! tree access_fun_b = DR_ACCESS_FN (DDR_B (ddr), i);
! 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;
}
--- 3504,3512 ----
unsigned i;
for (i = 0; i < DDR_NUM_SUBSCRIPTS (ddr); i++)
! if (!eq_evolutions_p (DR_ACCESS_FN (DDR_A (ddr), i),
! DR_ACCESS_FN (DDR_B (ddr), i)))
! return false;
return true;
}