aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJeff Law <law@gcc.gnu.org>1996-10-31 20:10:33 -0700
committerJeff Law <law@gcc.gnu.org>1996-10-31 20:10:33 -0700
commit3c00684e55149e43d4daa3a702668803fa6c8e15 (patch)
tree45414137ed5da40d6019a632d509c46603f585c8 /gcc/fold-const.c
parent273dbe6785ece0d5b76a98bbf2432c8316bbb4fd (diff)
downloadgcc-3c00684e55149e43d4daa3a702668803fa6c8e15.zip
gcc-3c00684e55149e43d4daa3a702668803fa6c8e15.tar.gz
gcc-3c00684e55149e43d4daa3a702668803fa6c8e15.tar.bz2
fold-const.c (make_range, [...]): Correct normalization of an unsigned range that wraps around zero.
* fold-const.c (make_range, case PLUS_EXPR): Correct normalization of an unsigned range that wraps around zero. From-SVN: r13089
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9e75466..e662403 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2814,10 +2814,16 @@ make_range (exp, pin_p, plow, phigh)
|| (n_high != 0 && TREE_OVERFLOW (n_high)))
break;
- /* Check for a range which has wrapped around the maximum value
- thus making n_high < n_low. Normalize any such range it. */
+ /* Check for an unsigned range which has wrapped around the maximum
+ value thus making n_high < n_low, and normalize it. */
if (n_low && n_high && tree_int_cst_lt (n_high, n_low))
- low = n_high, high = n_low, in_p = ! in_p;
+ {
+ low = range_binop (PLUS_EXPR, type, n_high, 0,
+ convert (type, integer_one_node), 0);
+ high = range_binop (MINUS_EXPR, type, n_low, 0,
+ convert (type, integer_one_node), 0);
+ in_p = ! in_p;
+ }
else
low = n_low, high = n_high;