diff options
author | Ian Lance Taylor <iant@google.com> | 2007-05-23 05:53:21 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2007-05-23 05:53:21 +0000 |
commit | b80cca7b47325f8c46d6f35c0a5d7aa17a28e7c5 (patch) | |
tree | 1980beba6fedbc0a5a4d5ca82a97a041f1f61a73 /gcc/tree-vrp.c | |
parent | 24016fdb16333fbe2a6fa54ab02828d8121cfe52 (diff) | |
download | gcc-b80cca7b47325f8c46d6f35c0a5d7aa17a28e7c5.zip gcc-b80cca7b47325f8c46d6f35c0a5d7aa17a28e7c5.tar.gz gcc-b80cca7b47325f8c46d6f35c0a5d7aa17a28e7c5.tar.bz2 |
tree-vrp.c (avoid_overflow_infinity): New static function, broken out of set_value_range_to_value.
* tree-vrp.c (avoid_overflow_infinity): New static function,
broken out of set_value_range_to_value.
(set_value_range_to_value): Call avoid_overflow_infinity.
(extract_range_from_assert): Likewise.
From-SVN: r124981
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index efb4f68..dda5dd1 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -201,6 +201,27 @@ is_overflow_infinity (tree val) || operand_equal_p (val, TYPE_MIN_VALUE (TREE_TYPE (val)), 0))); } +/* If VAL is now an overflow infinity, return VAL. Otherwise, return + the same value with TREE_OVERFLOW clear. This can be used to avoid + confusing a regular value with an overflow value. */ + +static inline tree +avoid_overflow_infinity (tree val) +{ + if (!is_overflow_infinity (val)) + return val; + + if (operand_equal_p (val, TYPE_MAX_VALUE (TREE_TYPE (val)), 0)) + return TYPE_MAX_VALUE (TREE_TYPE (val)); + else + { +#ifdef ENABLE_CHECKING + gcc_assert (operand_equal_p (val, TYPE_MIN_VALUE (TREE_TYPE (val)), 0)); +#endif + return TYPE_MIN_VALUE (TREE_TYPE (val)); + } +} + /* Return whether VAL is equal to the maximum value of its type. This will be true for a positive overflow infinity. We can't do a @@ -361,19 +382,7 @@ static inline void set_value_range_to_value (value_range_t *vr, tree val, bitmap equiv) { gcc_assert (is_gimple_min_invariant (val)); - if (is_overflow_infinity (val)) - { - if (operand_equal_p (val, TYPE_MAX_VALUE (TREE_TYPE (val)), 0)) - val = TYPE_MAX_VALUE (TREE_TYPE (val)); - else - { -#ifdef ENABLE_CHECKING - gcc_assert (operand_equal_p (val, - TYPE_MIN_VALUE (TREE_TYPE (val)), 0)); -#endif - val = TYPE_MIN_VALUE (TREE_TYPE (val)); - } - } + val = avoid_overflow_infinity (val); set_value_range (vr, VR_RANGE, val, val, equiv); } @@ -1103,6 +1112,8 @@ extract_range_from_assert (value_range_t *vr_p, tree expr) cond_code = swap_tree_comparison (TREE_CODE (cond)); } + limit = avoid_overflow_infinity (limit); + type = TREE_TYPE (limit); gcc_assert (limit != var); |