This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lno] fix number_of_iterations_in_loop
- From: Sebastian Pop <sebastian dot pop at cri dot ensmp dot fr>
- To: Dorit Naishlos <DORIT at il dot ibm dot com>
- Cc: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>, Olga Golovanevsky <OLGA at il dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 12 May 2004 11:47:14 +0200
- Subject: [lno] fix number_of_iterations_in_loop
- References: <20040512071217.GA17146@atrey.karlin.mff.cuni.cz> <OFA9FA260B.14B07757-ONC2256E92.002A6DBD-C2256E92.002BBD0E@il.ibm.com>
The following patch makes the scev analyzer use
number_of_iterations_cond instead of duplicating the code for
computing the loop counts. The patch removes also some old unused
code. Bootstrapped on amd64-unknown-freebsd5.2
* tree-chrec.c (chrec_evaluate): Use the type of the chrec
instead of integer_type_node when folding operations.
(chrec_apply): Factor chrec_type calls.
(chrec_eval_next_init_cond): Removed.
(chrec_convert): Don't propagate overflows introduced by convert.
* tree-chrec.h (chrec_eval_next_init_cond): Removed.
* tree-scalar-evolution.c (first_iteration_non_satisfying_noev_ev,
first_iteration_non_satisfying_ev_noev,
first_iteration_non_satisfying_ev_ev): Use number_of_iterations_cond
instead of computing the loop counts.
Index: tree-chrec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-chrec.c,v
retrieving revision 1.1.2.21
diff -c -3 -p -r1.1.2.21 tree-chrec.c
*** tree-chrec.c 6 May 2004 14:36:39 -0000 1.1.2.21
--- tree-chrec.c 12 May 2004 09:54:23 -0000
*************** chrec_evaluate (unsigned var,
*** 1158,1163 ****
--- 1158,1164 ----
tree n,
tree k)
{
+ tree type = chrec_type (chrec);
tree binomial_n_k = tree_fold_binomial (n, k);
if (TREE_CODE (chrec) == EXPONENTIAL_CHREC
*************** chrec_evaluate (unsigned var,
*** 1171,1188 ****
if (CHREC_VARIABLE (chrec) == var)
return chrec_fold_plus
! (chrec_type (chrec),
! chrec_fold_multiply (chrec_type (CHREC_LEFT (chrec)),
! binomial_n_k,
! CHREC_LEFT (chrec)),
chrec_evaluate (var, CHREC_RIGHT (chrec), n,
! tree_fold_plus (integer_type_node,
! k, integer_one_node)));
! return chrec_fold_multiply (chrec_type (chrec), binomial_n_k, chrec);
}
else
! return chrec_fold_multiply (chrec_type (chrec), binomial_n_k, chrec);
}
/* Evaluates "CHREC (X)" when the varying variable is VAR.
--- 1172,1186 ----
if (CHREC_VARIABLE (chrec) == var)
return chrec_fold_plus
! (type,
! chrec_fold_multiply (type, binomial_n_k, CHREC_LEFT (chrec)),
chrec_evaluate (var, CHREC_RIGHT (chrec), n,
! tree_fold_plus (type, k, integer_one_node)));
! return chrec_fold_multiply (type, binomial_n_k, chrec);
}
else
! return chrec_fold_multiply (type, binomial_n_k, chrec);
}
/* Evaluates "CHREC (X)" when the varying variable is VAR.
*************** chrec_apply (unsigned var,
*** 1201,1206 ****
--- 1199,1205 ----
tree chrec,
tree x)
{
+ tree type = chrec_type (chrec);
tree res = chrec_top;
if (automatically_generated_chrec_p (chrec)
*************** chrec_apply (unsigned var,
*** 1221,1234 ****
/* "{a, +, b} (x)" -> "a + b*x". */
if (TREE_CODE (CHREC_LEFT (chrec)) == INTEGER_CST
&& integer_zerop (CHREC_LEFT (chrec)))
! res = chrec_fold_multiply
! (chrec_type (chrec), CHREC_RIGHT (chrec), x);
else
! res = chrec_fold_plus (chrec_type (chrec),
! CHREC_LEFT (chrec),
! chrec_fold_multiply
! (chrec_type (chrec), CHREC_RIGHT (chrec), x));
}
else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC
--- 1220,1231 ----
/* "{a, +, b} (x)" -> "a + b*x". */
if (TREE_CODE (CHREC_LEFT (chrec)) == INTEGER_CST
&& integer_zerop (CHREC_LEFT (chrec)))
! res = chrec_fold_multiply (type, CHREC_RIGHT (chrec), x);
else
! res = chrec_fold_plus (type, CHREC_LEFT (chrec),
! chrec_fold_multiply (type,
! CHREC_RIGHT (chrec), x));
}
else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC
*************** reset_evolution_in_loop (unsigned loop_n
*** 1476,1527 ****
return build_polynomial_chrec (loop_num, chrec, new_evol);
}
-
- /* Returns the value of the variable after one execution of the loop
- LOOP_NB, supposing that CHREC is the evolution function of the
- variable.
-
- Example:
- chrec_eval_next_init_cond (4, {{1, +, 3}_2, +, 10}_4) = 11. */
-
- tree
- chrec_eval_next_init_cond (unsigned loop_nb,
- tree chrec)
- {
- tree init_cond;
-
- init_cond = initial_condition (chrec);
-
- if (TREE_CODE (chrec) == POLYNOMIAL_CHREC
- || TREE_CODE (chrec) == EXPONENTIAL_CHREC)
- {
- if (CHREC_VARIABLE (chrec) < loop_nb)
- /* There is no evolution in this dimension. */
- return init_cond;
-
- while ((TREE_CODE (CHREC_LEFT (chrec)) == POLYNOMIAL_CHREC
- || TREE_CODE (CHREC_LEFT (chrec)) == EXPONENTIAL_CHREC)
- && CHREC_VARIABLE (CHREC_LEFT (chrec)) >= loop_nb)
- chrec = CHREC_LEFT (chrec);
-
- if (CHREC_VARIABLE (chrec) != loop_nb)
- /* There is no evolution in this dimension. */
- return init_cond;
-
- if (TREE_CODE (chrec) == POLYNOMIAL_CHREC)
- /* testsuite/.../ssa-chrec-14.c */
- return chrec_fold_plus (chrec_type (init_cond), init_cond,
- initial_condition (CHREC_RIGHT (chrec)));
-
- else
- return chrec_fold_multiply (chrec_type (init_cond), init_cond,
- initial_condition (CHREC_RIGHT (chrec)));
- }
-
- else
- return init_cond;
- }
-
/* Determine the type of the result after the merge of types TYPE0 and
TYPE1. */
--- 1473,1478 ----
*************** chrec_convert (tree type,
*** 2001,2007 ****
chrec_convert (type, CHREC_UP (chrec)));
default:
! return convert (type, chrec);
}
}
--- 1952,1966 ----
chrec_convert (type, CHREC_UP (chrec)));
default:
! {
! tree res = convert (type, chrec);
!
! /* Don't propagate overflows. */
! TREE_OVERFLOW (res) = 0;
! if (TREE_CODE_CLASS (TREE_CODE (res)) == 'c')
! TREE_CONSTANT_OVERFLOW (res) = 0;
! return res;
! }
}
}
Index: tree-chrec.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-chrec.h,v
retrieving revision 1.1.2.19
diff -c -3 -p -r1.1.2.19 tree-chrec.h
*** tree-chrec.h 10 May 2004 15:23:53 -0000 1.1.2.19
--- tree-chrec.h 12 May 2004 09:54:23 -0000
*************** extern tree evolution_part_in_loop_num (
*** 85,91 ****
extern tree hide_evolution_in_other_loops_than_loop (tree, unsigned);
extern tree hide_evolution_in_loop (tree, unsigned);
extern tree reset_evolution_in_loop (unsigned, tree, tree);
- extern tree chrec_eval_next_init_cond (unsigned, tree);
extern tree chrec_merge (tree, tree);
extern tree chrec_fold_automatically_generated_operands (tree, tree);
--- 85,90 ----
Index: tree-scalar-evolution.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-scalar-evolution.c,v
retrieving revision 1.1.2.45
diff -c -3 -p -r1.1.2.45 tree-scalar-evolution.c
*** tree-scalar-evolution.c 10 May 2004 15:23:53 -0000 1.1.2.45
--- tree-scalar-evolution.c 12 May 2004 09:54:23 -0000
*************** first_iteration_non_satisfying_noev_ev (
*** 1122,1128 ****
/* tree tmax = TYPE_MAX_VALUE (type1); */
tree ev_in_this_loop;
tree init0, init1, step1;
! tree nb_iters;
ev_in_this_loop = hide_evolution_in_other_loops_than_loop (chrec1, loop_nb);
if (!evolution_function_is_affine_p (ev_in_this_loop))
--- 1122,1128 ----
/* tree tmax = TYPE_MAX_VALUE (type1); */
tree ev_in_this_loop;
tree init0, init1, step1;
! struct tree_niter_desc niter_desc;
ev_in_this_loop = hide_evolution_in_other_loops_than_loop (chrec1, loop_nb);
if (!evolution_function_is_affine_p (ev_in_this_loop))
*************** first_iteration_non_satisfying_noev_ev (
*** 1139,1365 ****
|| TREE_CODE (step1) != INTEGER_CST)
/* For the moment we deal only with INTEGER_CSTs. */
return chrec_top;
!
! switch (code)
! {
! case LE_EXPR:
! {
! if (tree_is_gt (init0, init1, &val) && val)
! {
! if (evolution_function_is_constant_p (chrec0))
! /* Example: "while (2 <= {0, +, 1}_2)". */
! return integer_zero_node;
! else
! /* Example: "while ({2, +, -1}_1 <= {0, +, 1}_2)". The
! number of iterations in loop_2 during the first two
! iterations of loop_1 is equal to 0. */
! return chrec_top;
! }
!
! if (tree_int_cst_sgn (step1) > 0)
! {
! if (evolution_function_is_constant_p (chrec0))
! /* Example: "while (2 <= {3, +, 1}_2)". */
! return chrec_top;
! /* nb_iters = tree_fold_plus
! (integer_type_node,
! tree_fold_floor_div (integer_type_node,
! tree_fold_minus (integer_type_node,
! tmax, init1),
! step1),
! integer_one_node);
! */
! else
! /* Example: "while ({2, +, 1}_1 <= {3, +, 1}_2)". */
! return chrec_top;
! }
!
! else
! {
! if (evolution_function_is_constant_p (chrec0)
! || tree_does_not_contain_chrecs (chrec0))
! /* Example: "while (2 <= {3, +, -1}_2)". */
! nb_iters = tree_fold_plus
! (type1,
! tree_fold_floor_div (type1,
! tree_fold_minus (type1, init1, init0),
! tree_fold_abs (type1, step1)),
! integer_one_node);
! else
! /* Example: "while ({2, +, 1}_1 <= {3, +, -1}_2)". */
! return chrec_top;
! }
!
! /* Verify the result. */
! if (tree_is_gt (init0,
! tree_fold_plus
! (type1, init1, tree_fold_multiply
! (type1, nb_iters, step1)), &val)
! && val)
! return nb_iters;
!
! else
! /* Difficult cases fall down there. Example: When the
! evolution step is big enough the wrapped value can be
! bigger than init0. In these cases the loop may end after
! several wraps, or never end. */
! return chrec_top;
! }
!
! case LT_EXPR:
! {
! if (tree_is_ge (init0, init1, &val) && val)
! {
! if (evolution_function_is_constant_p (chrec0))
! /* Example: "while (2 < {0, +, 1}_2)". */
! return integer_zero_node;
! else
! /* Example: "while ({2, +, 1}_1 < {0, +, 1}_2)". */
! return chrec_top;
! }
!
! if (tree_int_cst_sgn (step1) > 0)
! {
! if (evolution_function_is_constant_p (chrec0))
! /* Example: "while (2 < {3, +, 1}_2)". */
! return chrec_top;
! /* nb_iters = tree_fold_ceil_div
! (integer_type_node,
! tree_fold_minus (integer_type_node, tmax, init1),
! step1);
! */
! else
! /* Example: "while ({2, +, 1}_1 < {3, +, 1}_2)". */
! return chrec_top;
! }
! else
! {
! if (evolution_function_is_constant_p (chrec0)
! || tree_does_not_contain_chrecs (chrec0))
! /* Example: "while (2 < {3, +, -1}_2)". */
! nb_iters = tree_fold_ceil_div
! (type1,
! tree_fold_minus (type1, init1, init0),
! tree_fold_abs (type1, step1));
! else
! /* Example: "while ({2, +, 1}_1 < {3, +, -1}_2)". */
! return chrec_top;
! }
!
! /* Verify the result. */
! if (tree_is_ge (init0,
! tree_fold_plus
! (type1, init1, tree_fold_multiply
! (type1, nb_iters, step1)), &val)
! && val)
! return nb_iters;
!
! else
! /* Difficult cases fall down there. */
! return chrec_top;
! }
!
! case EQ_EXPR:
! {
! if (tree_is_ne (init0, init1, &val) && val)
! {
! if (evolution_function_is_constant_p (chrec0))
! /* Example: "while (2 == {0, +, 1}_2)". */
! return integer_zero_node;
! else
! /* Example: "while ({2, +, -1}_1 == {0, +, 1}_2)". */
! return chrec_top;
! }
!
! if (evolution_function_is_constant_p (chrec0))
! {
! if (integer_zerop (step1))
! /* Example: "while (2 == {2, +, 0}_2)". */
! return chrec_bot;
! else
! return integer_one_node;
! }
! else
! return chrec_top;
! }
!
! case NE_EXPR:
! {
! if (tree_is_eq (init0, init1, &val) && val)
! {
! if (evolution_function_is_constant_p (chrec0))
! /* Example: "while (0 != {0, +, 1}_2)". */
! return integer_zero_node;
! else
! /* Example: "while ({0, +, -1}_1 != {0, +, 1}_2)". */
! return chrec_top;
! }
!
! if (tree_int_cst_sgn (step1) > 0)
! {
! if (evolution_function_is_constant_p (chrec0)
! || tree_does_not_contain_chrecs (chrec0))
! {
! if (tree_is_gt (init0, init1, &val) && val)
! {
! tree diff = tree_fold_minus (type1, init0, init1);
! if (tree_fold_divides_p (type1, step1, diff))
! /* Example: "while (3 != {2, +, 1}_2)". */
! nb_iters = tree_fold_exact_div (type1, diff, step1);
! else
! /* Example: "while (3 != {2, +, 2}_2)". */
! return chrec_top;
! }
! else
! /* Example: "while (2 != {3, +, 1}_2)". */
! return chrec_top;
! }
! else
! /* Example: "while ({2, +, 1}_1 != {3, +, 1}_2)". */
! return chrec_top;
! }
!
! else
! {
! if (evolution_function_is_constant_p (chrec0)
! || tree_does_not_contain_chrecs (chrec0))
! {
! if (tree_is_lt (init0, init1, &val) && val)
! {
! tree diff = tree_fold_minus (type1, init1, init0);
! if (tree_fold_divides_p (type1, step1, diff))
! /* Example: "while (2 != {3, +, -1}_2)". */
! nb_iters = tree_fold_exact_div
! (type1, diff, tree_fold_abs (type1, step1));
! else
! /* Example: "while (2 != {3, +, -2}_2)". */
! return chrec_top;
! }
! else
! /* Example: "while (3 != {2, +, -1}_2)". */
! return chrec_top;
! }
! else
! /* Example: "while ({2, +, 1}_1 != {3, +, -1}_2)". */
! return chrec_top;
! }
!
! /* Verify the result. */
! if (tree_is_eq (init0,
! tree_fold_plus
! (type1, init1, tree_fold_multiply
! (type1, nb_iters, step1)), &val)
! && val)
! return nb_iters;
!
! else
! /* Difficult cases fall down there. */
! return chrec_top;
! }
!
! default:
! return chrec_top;
! }
return chrec_top;
}
--- 1139,1150 ----
|| TREE_CODE (step1) != INTEGER_CST)
/* For the moment we deal only with INTEGER_CSTs. */
return chrec_top;
!
! niter_desc.niter = NULL_TREE;
! number_of_iterations_cond (type1, init0, NULL_TREE, code, init1, step1,
! &niter_desc);
! if (niter_desc.niter != NULL_TREE)
! return niter_desc.niter;
return chrec_top;
}
*************** first_iteration_non_satisfying_ev_noev (
*** 1377,1384 ****
/* tree tmin = TYPE_MIN_VALUE (type0); */
tree ev_in_this_loop;
tree init0, init1, step0;
! tree nb_iters;
!
ev_in_this_loop = hide_evolution_in_other_loops_than_loop (chrec0, loop_nb);
if (!evolution_function_is_affine_p (ev_in_this_loop))
/* For the moment handle only polynomials of degree 1. */
--- 1162,1169 ----
/* tree tmin = TYPE_MIN_VALUE (type0); */
tree ev_in_this_loop;
tree init0, init1, step0;
! struct tree_niter_desc niter_desc;
!
ev_in_this_loop = hide_evolution_in_other_loops_than_loop (chrec0, loop_nb);
if (!evolution_function_is_affine_p (ev_in_this_loop))
/* For the moment handle only polynomials of degree 1. */
*************** first_iteration_non_satisfying_ev_noev (
*** 1394,1626 ****
|| TREE_CODE (step0) != INTEGER_CST)
/* For the moment we deal only with INTEGER_CSTs. */
return chrec_top;
-
- switch (code)
- {
- case LE_EXPR:
- {
- if (tree_is_gt (init0, init1, &val) && val)
- {
- if (evolution_function_is_constant_p (chrec1))
- /* Example: "while ({2, +, 1}_2 <= 0)". */
- return integer_zero_node;
-
- else
- /* Example: "while ({2, +, 1}_2 <= {0, +, 1}_1)". */
- return chrec_top;
- }
-
- if (tree_int_cst_sgn (step0) < 0)
- {
- if (evolution_function_is_constant_p (chrec1))
- /* Example: "while ({2, +, -1}_2 <= 3)". */
- return chrec_top;
- /* nb_iters = tree_fold_plus
- (integer_type_node,
- tree_fold_floor_div (integer_type_node,
- tree_fold_minus (integer_type_node,
- init0, tmin),
- tree_fold_abs (integer_type_node,
- step0)),
- integer_one_node);
- */
- else
- /* Example: "while ({2, +, -1}_2 <= {3, +, 1}_1)". */
- return chrec_top;
- }
- else
- {
- if (evolution_function_is_constant_p (chrec1)
- || tree_does_not_contain_chrecs (chrec1))
- /* Example: "while ({2, +, 1}_2 <= 3)". */
- nb_iters = tree_fold_plus
- (type0,
- tree_fold_floor_div (type0,
- tree_fold_minus (type0, init1, init0),
- step0),
- integer_one_node);
- else
- /* Example: "while ({2, +, 1}_2 <= {3, +, 1}_1)". */
- return chrec_top;
- }
-
- /* Verify the result. */
- if (tree_is_gt (tree_fold_plus
- (type0, init0, tree_fold_multiply
- (type0, nb_iters, step0)), init1, &val)
- && val)
- return nb_iters;
-
- else
- /* Difficult cases fall down there. */
- return chrec_top;
- }
-
- case LT_EXPR:
- {
- if (tree_is_ge (init0, init1, &val) && val)
- {
- if (evolution_function_is_constant_p (chrec1))
- /* Example: "while ({2, +, 1}_2 < 0)". */
- return integer_zero_node;
-
- else
- /* Example: "while ({2, +, 1}_2 < {0, +, 1}_1)". */
- return chrec_top;
- }
-
- if (tree_int_cst_sgn (step0) < 0)
- {
- if (evolution_function_is_constant_p (chrec1))
- /* Example: "while ({2, +, -1}_2 < 3)". */
- return chrec_top;
- /* nb_iters = tree_fold_ceil_div
- (integer_type_node,
- tree_fold_minus (integer_type_node, init0, tmin),
- tree_fold_abs (integer_type_node, step0));
- */
- else
- /* Example: "while ({2, +, -1}_2 < {3, +, 1}_1)". */
- return chrec_top;
- }
- else
- {
- if (evolution_function_is_constant_p (chrec1)
- || tree_does_not_contain_chrecs (chrec1))
- /* Example: "while ({2, +, 1}_2 < 3)". */
- nb_iters = tree_fold_ceil_div
- (type0, tree_fold_minus (type0, init1, init0), step0);
- else
- /* Example: "while ({2, +, 1}_2 < {3, +, 1}_1)". */
- return chrec_top;
- }
-
- /* Verify the result. */
- if (tree_is_ge (tree_fold_plus (type0, init0,
- tree_fold_multiply (type0, nb_iters,
- step0)),
- init1, &val)
- && val)
- return nb_iters;
-
- else
- /* Difficult cases fall down there. */
- return chrec_top;
- }
-
- case EQ_EXPR:
- {
- if (tree_is_ne (init0, init1, &val) && val)
- {
- if (evolution_function_is_constant_p (chrec1))
- /* Example: "while ({2, +, 1}_2 == 0)". */
- return integer_zero_node;
- else
- /* Example: "while ({2, +, -1}_2 == {0, +, 1}_1)". */
- return chrec_top;
- }
-
- if (evolution_function_is_constant_p (chrec1))
- {
- if (integer_zerop (step0))
- /* Example: "while ({2, +, 0}_2 == 2)". */
- return chrec_bot;
- else
- return integer_one_node;
- }
- else
- return chrec_top;
- }
-
- case NE_EXPR:
- {
- if (tree_is_eq (init0, init1, &val) && val)
- {
- if (evolution_function_is_constant_p (chrec1))
- /* Example: "while ({0, +, 1}_2 != 0)". */
- return integer_zero_node;
- else
- /* Example: "while ({0, +, -1}_2 != {0, +, 1}_1)". */
- return chrec_top;
- }
-
- if (tree_int_cst_sgn (step0) > 0)
- {
- if (evolution_function_is_constant_p (chrec1)
- || tree_does_not_contain_chrecs (chrec1))
- {
- if (tree_is_lt (init0, init1, &val) && val)
- {
- tree diff = tree_fold_minus (type0, init1, init0);
- if (tree_fold_divides_p (type0, step0, diff))
- /* Example: "while ({2, +, 1}_2 != 3)". */
- nb_iters = tree_fold_exact_div (type0, diff, step0);
- else
- /* Example: "while ({2, +, 2}_2 != 3)". */
- return chrec_top;
- }
- else
- /* Example: "while ({3, +, 1}_2 != 2)". */
- return chrec_top;
- }
- else
- /* Example: "while ({2, +, 1}_2 != {3, +, 1}_1)". */
- return chrec_top;
- }
-
- else
- {
- if (evolution_function_is_constant_p (chrec1)
- || tree_does_not_contain_chrecs (chrec1))
- {
- if (tree_is_gt (init0, init1, &val) && val)
- {
- tree diff = tree_fold_minus (type0, init0, init1);
- if (tree_fold_divides_p (type0, step0, diff))
- /* Example: "while ({3, +, -1}_2 != 2)". */
- nb_iters = tree_fold_exact_div
- (type0, diff, tree_fold_abs (integer_type_node,
- step0));
- else
- /* Example: "while ({3, +, -2}_2 != 2)". */
- return chrec_top;
- }
- else
- /* Example: "while ({2, +, -1}_2 != 3)". */
- return chrec_top;
- }
- else
- /* Example: "while ({2, +, -1}_2 != {3, +, -1}_1)". */
- return chrec_top;
- }
-
- /* Verify the result. */
- if (tree_is_eq (tree_fold_plus
- (type0, init0, tree_fold_multiply
- (type0, nb_iters, step0)), init1, &val)
- && val)
- return nb_iters;
- else
- /* Difficult cases fall down there. */
- return chrec_top;
- }
-
- default:
- return chrec_top;
- }
-
- return chrec_top;
- }
! static inline tree
! number_of_iterations_to_overflow (tree type, tree init, tree step)
! {
! return tree_fold_plus
! (integer_type_node, integer_one_node,
! tree_fold_ceil_div (integer_type_node,
! tree_fold_minus (integer_type_node,
! TYPE_MAX_VALUE (type), init),
! step));
}
/* Helper function for the case when both CHREC0 and CHREC1 has an
--- 1179,1191 ----
|| TREE_CODE (step0) != INTEGER_CST)
/* For the moment we deal only with INTEGER_CSTs. */
return chrec_top;
! niter_desc.niter = NULL_TREE;
! number_of_iterations_cond (type0, init0, step0, code, init1, NULL_TREE,
! &niter_desc);
! if (niter_desc.niter != NULL_TREE)
! return niter_desc.niter;
! return chrec_top;
}
/* Helper function for the case when both CHREC0 and CHREC1 has an
*************** first_iteration_non_satisfying_ev_ev (en
*** 1635,1642 ****
bool val = false;
tree init0, init1, step0, step1;
tree type0, type1;
! tree nb_iters;
! int sign_step0, sign_step1;
if (evolution_function_is_multivariate (chrec0)
|| evolution_function_is_multivariate (chrec1))
--- 1200,1206 ----
bool val = false;
tree init0, init1, step0, step1;
tree type0, type1;
! struct tree_niter_desc niter_desc;
if (evolution_function_is_multivariate (chrec0)
|| evolution_function_is_multivariate (chrec1))
*************** first_iteration_non_satisfying_ev_ev (en
*** 1656,1736 ****
/* For the moment, we deal only with INTEGER_CSTs. */
return chrec_top;
- sign_step0 = tree_int_cst_sgn (step0);
- sign_step1 = tree_int_cst_sgn (step1);
type0 = chrec_type (chrec0);
type1 = chrec_type (chrec1);
! debug_generic_expr (chrec0);
! debug_generic_expr (chrec1);
!
! switch (code)
! {
! case LE_EXPR:
! case LT_EXPR:
! {
! if (tree_is_gt (init0, init1, &val) && val)
! return integer_zero_node;
!
! if (sign_step0 > 0 && sign_step1 > 0)
! {
! if (tree_is_eq (step0, step1, &val) && val)
! {
! /* The loop ends after an overflow, for example:
! "while ({1, +, 2}_1 <= {2, +, 2}_1)". */
! if (type0 != type1)
! return chrec_top;
!
! return number_of_iterations_to_overflow (type1, init1, step1);
! }
!
! if (tree_is_gt (step0, step1, &val) && val)
! {
! /* "while ({0, +, 2}_1 <= {2, +, 1}_1)". */
! nb_iters = tree_fold_plus
! (integer_type_node,
! ((code == LE_EXPR) ?
! build_int_cst (integer_type_node, 2) : integer_one_node),
! tree_fold_ceil_div
! (integer_type_node,
! tree_fold_minus (integer_type_node, init1, init0),
! tree_fold_minus (integer_type_node, step0, step1)));
!
! /* Verify that chrec1 is not overflowing after nb_iters. */
! if (!TREE_OVERFLOW (chrec_apply (CHREC_VARIABLE (chrec1),
! chrec1, nb_iters)))
! return nb_iters;
!
! if (type0 != type1)
! return chrec_top;
!
! return number_of_iterations_to_overflow (type1, init1, step1);
! }
!
! return chrec_top;
! }
!
! else if (sign_step0 < 0 && sign_step1 < 0)
! return chrec_top;
!
! else if (sign_step0 < 0 && sign_step1 > 0)
! return chrec_top;
!
! else if (sign_step0 > 0 && sign_step1 < 0)
! return chrec_top;
!
! else
! return chrec_top;
! }
!
! case EQ_EXPR:
!
! case NE_EXPR:
!
! default:
! return chrec_top;
! }
!
return chrec_top;
}
--- 1220,1235 ----
/* For the moment, we deal only with INTEGER_CSTs. */
return chrec_top;
type0 = chrec_type (chrec0);
type1 = chrec_type (chrec1);
+ if (type0 != type1)
+ return chrec_top;
! niter_desc.niter = NULL_TREE;
! number_of_iterations_cond (type0, init0, step0, code, init1, step1,
! &niter_desc);
! if (niter_desc.niter != NULL_TREE)
! return niter_desc.niter;
return chrec_top;
}