diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-15 17:35:48 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-05-15 17:35:48 +0000 |
commit | d4eedd54002cea3d0d765cac21307aa09832cfc6 (patch) | |
tree | 346efb9b7010a61806bedde644eb95404dec240d /gcc/tree-ssa-loop-niter.c | |
parent | 947f2aa131a2169dd755507cadcf5ba63dd8b842 (diff) | |
download | gcc-d4eedd54002cea3d0d765cac21307aa09832cfc6.tar.gz |
2006-05-15 Richard Guenther <rguenther@suse.de>
PR tree-optimization/27603
* tree-ssa-loop-niter.c (infer_loop_bounds_from_undefined):
Do computations in original type.
* gcc.dg/torture/pr27603.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113797 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r-- | gcc/tree-ssa-loop-niter.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index a3c5791208f..4dd05ea6d16 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1587,7 +1587,6 @@ infer_loop_bounds_from_undefined (struct loop *loop) tree scev = instantiate_parameters (loop, analyze_scalar_evolution (loop, op0)); tree type = chrec_type (scev); - tree utype; if (chrec_contains_undetermined (scev) || TYPE_UNSIGNED (type)) @@ -1604,20 +1603,23 @@ infer_loop_bounds_from_undefined (struct loop *loop) || TYPE_MAX_VALUE (type) == NULL_TREE) break; - utype = unsigned_type_for (type); - if (tree_int_cst_lt (step, integer_zero_node)) - diff = fold_build2 (MINUS_EXPR, utype, init, - TYPE_MIN_VALUE (type)); - else - diff = fold_build2 (MINUS_EXPR, utype, - TYPE_MAX_VALUE (type), init); - - if (!integer_zerop (step)) + if (integer_nonzerop (step)) { - estimation = fold_build2 (CEIL_DIV_EXPR, utype, diff, + tree utype; + + if (tree_int_cst_lt (step, integer_zero_node)) + diff = fold_build2 (MINUS_EXPR, type, init, + TYPE_MIN_VALUE (type)); + else + diff = fold_build2 (MINUS_EXPR, type, + TYPE_MAX_VALUE (type), init); + + utype = unsigned_type_for (type); + estimation = fold_build2 (CEIL_DIV_EXPR, type, diff, step); - record_estimate (loop, estimation, boolean_true_node, - stmt); + record_estimate (loop, + fold_convert (utype, estimation), + boolean_true_node, stmt); } } |