diff options
author | Jan Hubicka <jh@suse.cz> | 2006-12-07 13:54:09 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2006-12-07 12:54:09 +0000 |
commit | 5daffcc76eab6e3b4519fbc9aa8af59ff70d6ef0 (patch) | |
tree | 0497c34bbec6df88f11ebc345173a927e791df5f | |
parent | 58f76679659f6d1e107bf9d2072a2f7bca63c763 (diff) | |
download | gcc-5daffcc76eab6e3b4519fbc9aa8af59ff70d6ef0.zip gcc-5daffcc76eab6e3b4519fbc9aa8af59ff70d6ef0.tar.gz gcc-5daffcc76eab6e3b4519fbc9aa8af59ff70d6ef0.tar.bz2 |
tree-vrp.c (compare_values): Short circuit INTEGER_CST...
* tree-vrp.c (compare_values): Short circuit INTEGER_CST;
use fold_constant_to_binary; tolerate wrong type constants.
(value_intersect_p): Do just two tests.
From-SVN: r119619
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 27 |
2 files changed, 25 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad6b37e..aac2bb1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-12-07 Jan Hubicka <jh@suse.cz> + + * tree-vrp.c (compare_values): Short circuit INTEGER_CST; + use fold_constant_to_binary; tolerate wrong type constants. + (value_intersect_p): Do just two tests. + 2006-12-07 Bernd Schmidt <bernd.schmidt@analog.com> * config/bfin/bfin.c (print_operand): New modifier 'N' for constants. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 908f22b..eb28ca9 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -620,10 +620,17 @@ compare_values (tree val1, tree val2) if (operand_less_p (val2, val1) == 1) return 1; - /* If VAL1 is different than VAL2, return +2. */ - t = fold_binary (NE_EXPR, boolean_type_node, val1, val2); - if (t == boolean_true_node) - return 2; + /* If VAL1 is different than VAL2, return +2. + For integer constants we either have already returned -1 or 1 + or they are equivalent. We still might suceed prove something + about non-trivial operands. */ + if (TREE_CODE (val1) != INTEGER_CST + || TREE_CODE (val2) != INTEGER_CST) + { + t = fold_binary_to_constant (NE_EXPR, boolean_type_node, val1, val2); + if (t && tree_expr_nonzero_p (t)) + return 2; + } return -2; } @@ -682,10 +689,14 @@ value_inside_range (tree val, value_range_t * vr) static inline bool value_ranges_intersect_p (value_range_t *vr0, value_range_t *vr1) { - return (value_inside_range (vr1->min, vr0) == 1 - || value_inside_range (vr1->max, vr0) == 1 - || value_inside_range (vr0->min, vr1) == 1 - || value_inside_range (vr0->max, vr1) == 1); + /* The value ranges do not intersect if the maximum of the first range is + less than the minimum of the second range or vice versa. + When those relations are unknown, we can't do any better. */ + if (operand_less_p (vr0->max, vr1->min) != 0) + return false; + if (operand_less_p (vr1->max, vr0->min) != 0) + return false; + return true; } |