diff options
author | Richard Biener <rguenth@gcc.gnu.org> | 2011-08-12 11:29:01 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-08-12 11:29:01 +0000 |
commit | d9fbc86e446fd574db0d79c3af8d0bd2b1cdc820 (patch) | |
tree | 4beb9de21a1a0f7c219d6dae43e294670ad8b078 | |
parent | 6aeb8c9919b5b816a32fcf8400b85d9b91752059 (diff) | |
download | gcc-d9fbc86e446fd574db0d79c3af8d0bd2b1cdc820.zip gcc-d9fbc86e446fd574db0d79c3af8d0bd2b1cdc820.tar.gz gcc-d9fbc86e446fd574db0d79c3af8d0bd2b1cdc820.tar.bz2 |
tree-vrp.c (extract_range_from_unary_expr_1): Implement -X as 0 - X.
2011-08-12 Richard Guenther <rguenther@suse.de>
* tree-vrp.c (extract_range_from_unary_expr_1): Implement
-X as 0 - X.
From-SVN: r177693
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 67 |
2 files changed, 13 insertions, 61 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b53080e..e708c8e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,9 @@ -2011-08-02 Romain Geissler <romain.geissler@gmail.com> +2011-08-12 Richard Guenther <rguenther@suse.de> + + * tree-vrp.c (extract_range_from_unary_expr_1): Implement + -X as 0 - X. + +2011-08-12 Romain Geissler <romain.geissler@gmail.com> * Makefile.in (PLUGIN_HEADERS): Add C_TREE_H. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 6944b42..df7a9a2 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2946,67 +2946,14 @@ extract_range_from_unary_expr_1 (value_range_t *vr, /* Apply the operation to each end of the range and see what we end up with. */ - if (code == NEGATE_EXPR - && !TYPE_UNSIGNED (type)) - { - /* NEGATE_EXPR flips the range around. We need to treat - TYPE_MIN_VALUE specially. */ - if (is_positive_overflow_infinity (vr0.max)) - min = negative_overflow_infinity (type); - else if (is_negative_overflow_infinity (vr0.max)) - min = positive_overflow_infinity (type); - else if (!vrp_val_is_min (vr0.max)) - min = fold_unary_to_constant (code, type, vr0.max); - else if (needs_overflow_infinity (type)) - { - if (supports_overflow_infinity (type) - && !is_overflow_infinity (vr0.min) - && !vrp_val_is_min (vr0.min)) - min = positive_overflow_infinity (type); - else - { - set_value_range_to_varying (vr); - return; - } - } - else - min = TYPE_MIN_VALUE (type); - - if (is_positive_overflow_infinity (vr0.min)) - max = negative_overflow_infinity (type); - else if (is_negative_overflow_infinity (vr0.min)) - max = positive_overflow_infinity (type); - else if (!vrp_val_is_min (vr0.min)) - max = fold_unary_to_constant (code, type, vr0.min); - else if (needs_overflow_infinity (type)) - { - if (supports_overflow_infinity (type)) - max = positive_overflow_infinity (type); - else - { - set_value_range_to_varying (vr); - return; - } - } - else - max = TYPE_MIN_VALUE (type); - } - else if (code == NEGATE_EXPR - && TYPE_UNSIGNED (type)) + if (code == NEGATE_EXPR) { - if (!range_includes_zero_p (&vr0)) - { - max = fold_unary_to_constant (code, type, vr0.min); - min = fold_unary_to_constant (code, type, vr0.max); - } - else - { - if (range_is_null (&vr0)) - set_value_range_to_null (vr, type); - else - set_value_range_to_varying (vr); - return; - } + /* -X is simply 0 - X, so re-use existing code that also handles + anti-ranges fine. */ + value_range_t zero = { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL }; + set_value_range_to_value (&zero, build_int_cst (type, 0), NULL); + extract_range_from_binary_expr_1 (vr, MINUS_EXPR, type, &zero, &vr0); + return; } else if (code == ABS_EXPR && !TYPE_UNSIGNED (type)) |