From 019d6598357659e05640cf762b75e18953f70fe9 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 7 Jul 2016 13:50:55 +0200 Subject: [PATCH] tree-scalar-evolution.c (iv_can_overflow_p): export. * tree-scalar-evolution.c (iv_can_overflow_p): export. * tree-scalar-evolution.h (iv_can_overflow_p): Declare. * tree-ssa-loop-ivopts.c (alloc_iv): Use it. From-SVN: r238088 --- gcc/ChangeLog | 6 ++++++ gcc/tree-scalar-evolution.c | 2 +- gcc/tree-scalar-evolution.h | 1 + gcc/tree-ssa-loop-ivopts.c | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 75f39de42c0..fca1bac78e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-07-07 Jan Hubicka + + * tree-scalar-evolution.c (iv_can_overflow_p): export. + * tree-scalar-evolution.h (iv_can_overflow_p): Declare. + * tree-ssa-loop-ivopts.c (alloc_iv): Use it. + 2016-07-07 Ilya Enkovich PR ipa/71624 diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index e51f0aaedc1..2097d81b6cb 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -3317,7 +3317,7 @@ scev_reset (void) use this test even for derived IVs not computed every iteration or hypotetical IVs to be inserted into code. */ -static bool +bool iv_can_overflow_p (struct loop *loop, tree type, tree base, tree step) { widest_int nit; diff --git a/gcc/tree-scalar-evolution.h b/gcc/tree-scalar-evolution.h index 8a87660cfbe..382d71751cc 100644 --- a/gcc/tree-scalar-evolution.h +++ b/gcc/tree-scalar-evolution.h @@ -38,6 +38,7 @@ extern unsigned int scev_const_prop (void); extern bool expression_expensive_p (tree); extern bool simple_iv (struct loop *, struct loop *, tree, struct affine_iv *, bool); +extern bool iv_can_overflow_p (struct loop *, tree, tree, tree); extern tree compute_overall_effect_of_inner_loop (struct loop *, tree); /* Returns the basic block preceding LOOP, or the CFG entry block when diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 25b97808512..6b403f5b72f 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1181,6 +1181,10 @@ alloc_iv (struct ivopts_data *data, tree base, tree step, iv->biv_p = false; iv->nonlin_use = NULL; iv->ssa_name = NULL_TREE; + if (!no_overflow + && !iv_can_overflow_p (data->current_loop, TREE_TYPE (base), + base, step)) + no_overflow = true; iv->no_overflow = no_overflow; iv->have_address_use = false; -- 2.30.2