aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-niter.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r--gcc/tree-ssa-loop-niter.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index d3007d7..a9b7077 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -3011,7 +3011,12 @@ discover_iteration_bound_by_body_walk (struct loop *loop)
/* Exit terminates loop at given iteration, while non-exits produce undefined
effect on the next iteration. */
if (!elt->is_exit)
- bound += double_int_one;
+ {
+ bound += double_int_one;
+ /* If an overflow occurred, ignore the result. */
+ if (bound.is_zero ())
+ continue;
+ }
if (!loop->any_upper_bound
|| bound.ult (loop->nb_iterations_upper_bound))
@@ -3037,7 +3042,12 @@ discover_iteration_bound_by_body_walk (struct loop *loop)
{
double_int bound = elt->bound;
if (!elt->is_exit)
- bound += double_int_one;
+ {
+ bound += double_int_one;
+ /* If an overflow occurred, ignore the result. */
+ if (bound.is_zero ())
+ continue;
+ }
if (!loop->any_upper_bound
|| bound.ult (loop->nb_iterations_upper_bound))