aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@redhat.com>2005-06-15 15:19:51 +0000
committerDiego Novillo <dnovillo@redhat.com>2005-06-15 15:19:51 +0000
commitca40505b6a6e8208e4f438018ba41d84551e368f (patch)
tree4661bb0b3249ca39b4637e0ce4e79fca3a9451e4 /gcc/tree-vrp.c
parentcbea5b4384780ffb43e8dee3cbad673b4f35f242 (diff)
* tree-vrp.c (vrp_int_const_binop): Do not handle MAX_EXPR
when the result overflows. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@100983 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 2569267ccf8..c0d0514cf60 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -996,9 +996,15 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2)
int sgn1 = tree_int_cst_sgn (val1);
int sgn2 = tree_int_cst_sgn (val2);
- /* Notice that we only need to handle the restricted set of
- operations handled by extract_range_from_binary_expr. */
- if (((code == PLUS_EXPR || code == MAX_EXPR) && sgn2 >= 0)
+ /* Determine whether VAL1 CODE VAL2 yields a growing value.
+ Notice that we only need to handle the restricted set of
+ operations handled by extract_range_from_binary_expr:
+
+ VAL1 + VAL2 grows if VAL2 is >= 0.
+ VAL1 * VAL2 grows if both VAL1 and VAL2 have the same sign.
+ VAL1 - VAL2 grows if VAL2 is < 0 (because it becomes an addition).
+ */
+ if ((code == PLUS_EXPR && sgn2 >= 0)
|| (code == MULT_EXPR && sgn1 == sgn2)
|| (code == MINUS_EXPR && sgn2 < 0))
grows = true;