diff options
author | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-08-06 05:35:31 +0000 |
---|---|---|
committer | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-08-06 05:35:31 +0000 |
commit | 0bca07905c9d4b86557a63e24e2361ef37f3c141 (patch) | |
tree | 2e47c97b535d7d1d721621ee6339c61536de7863 /gcc/tree-vrp.c | |
parent | 05b01572aaf20512a5376376788da1e41d7e35c2 (diff) | |
download | gcc-0bca07905c9d4b86557a63e24e2361ef37f3c141.tar.gz |
2005-08-05 James A. Morrison <phython@gcc.gnu.org>
PR tree-optimization/23128
* tree-vrp.c (vrp_int_const_binop): Check if unsigned addition or
subtraction wrap, and set TREE_OVERFLOW if they do.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102800 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 68bcb1e6a8f..a77be8479cd 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -915,12 +915,25 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2) on -INF and +INF. */ res = int_const_binop (code, val1, val2, 0); + if (TYPE_UNSIGNED (TREE_TYPE (val1))) + { + int checkz = compare_values (res, val1); + + /* Ensure that res = val1 + val2 >= val1 + or that res = val1 - val2 <= val1. */ + if ((code == PLUS_EXPR && !(checkz == 1 || checkz == 0)) + || (code == MINUS_EXPR && !(checkz == 0 || checkz == -1))) + { + res = copy_node (res); + TREE_OVERFLOW (res) = 1; + } + } /* If the operation overflowed but neither VAL1 nor VAL2 are overflown, return -INF or +INF depending on the operation and the combination of signs of the operands. */ - if (TREE_OVERFLOW (res) - && !TREE_OVERFLOW (val1) - && !TREE_OVERFLOW (val2)) + else if (TREE_OVERFLOW (res) + && !TREE_OVERFLOW (val1) + && !TREE_OVERFLOW (val2)) { int sgn1 = tree_int_cst_sgn (val1); int sgn2 = tree_int_cst_sgn (val2); |