diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-30 11:15:20 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-30 11:15:20 +0000 |
commit | 29b71b9ccd507ac24e12f9b7bb72276b571e09d6 (patch) | |
tree | 461b8951a8882fd9c13e1232291f8e317d76f105 /gcc/tree-vrp.c | |
parent | c8126d259bbe1b1b085d12bdf818c3f16d0d5433 (diff) | |
download | gcc-29b71b9ccd507ac24e12f9b7bb72276b571e09d6.tar.gz |
2011-05-30 Richard Guenther <rguenther@suse.de>
PR tree-optimization/49218
* tree-vrp.c (adjust_range_with_scev): Properly check whether
overflow occured.
* gcc.c-torture/execute/pr49218.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174429 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 8fcf629adde..f40d0d4c890 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -3423,11 +3423,17 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop, loop->nb_iterations_upper_bound, double_int_one), unsigned_p, &overflow); - tem = double_int_to_tree (TREE_TYPE (init), dtmp); /* If the multiplication overflowed we can't do a meaningful - adjustment. */ - if (!overflow && double_int_equal_p (dtmp, tree_to_double_int (tem))) - { + adjustment. Likewise if the result doesn't fit in the type + of the induction variable. For a signed type we have to + check whether the result has the expected signedness which + is that of the step as nb_iterations_upper_bound is unsigned. */ + if (!overflow + && double_int_fits_to_tree_p (TREE_TYPE (init), dtmp) + && (unsigned_p + || ((dtmp.high ^ TREE_INT_CST_HIGH (step)) >= 0))) + { + tem = double_int_to_tree (TREE_TYPE (init), dtmp); extract_range_from_binary_expr (&maxvr, PLUS_EXPR, TREE_TYPE (init), init, tem); /* Likewise if the addition did. */ |