diff options
author | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1996-11-01 14:49:54 +0000 |
---|---|---|
committer | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1996-11-01 14:49:54 +0000 |
commit | a9e29e867e0497dc42618b4fb2df84d74fe8b776 (patch) | |
tree | f868efe11411e435958741cb45f8f06e65047e16 /gcc/fold-const.c | |
parent | 6b457c771fc92a8e43ea0df5a439411769f90542 (diff) | |
download | gcc-a9e29e867e0497dc42618b4fb2df84d74fe8b776.tar.gz |
(make_range): Don't merge unsigned case with range containing upper bound;
instead merge just with zero and convert a range with no upper bound to
opposite one with no lower bound.
(merge_ranges): In (+,-) case, don't treat subset specially if the upper
bounds are the same; fix typo in others case here.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@13090 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e66240326e9..dabcf29b012 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2763,22 +2763,27 @@ make_range (exp, pin_p, plow, phigh) exp = arg0; /* If this is an unsigned comparison, we also know that EXP is - greater than or equal to zero and less than the maximum value of - the unsigned type. We base the range tests we make on that fact, - so we record it here so we can parse existing range tests. */ + greater than or equal to zero. We base the range tests we make + on that fact, so we record it here so we can parse existing + range tests. */ if (TREE_UNSIGNED (type) && (low == 0 || high == 0)) { if (! merge_ranges (&n_in_p, &n_low, &n_high, in_p, low, high, 1, convert (type, integer_zero_node), - const_binop (MINUS_EXPR, - convert (type, - integer_zero_node), - convert (type, - integer_one_node), - 0))) + NULL_TREE)) break; in_p = n_in_p, low = n_low, high = n_high; + + /* If the high bound is missing, reverse the range so it + goes from zero to the low bound minus 1. */ + if (high == 0) + { + in_p = ! in_p; + high = range_binop (MINUS_EXPR, NULL_TREE, low, 0, + integer_one_node, 0); + low = convert (type, integer_zero_node); + } } continue; @@ -2819,9 +2824,9 @@ make_range (exp, pin_p, plow, phigh) if (n_low && n_high && tree_int_cst_lt (n_high, n_low)) { low = range_binop (PLUS_EXPR, type, n_high, 0, - convert (type, integer_one_node), 0); + integer_one_node, 0); high = range_binop (MINUS_EXPR, type, n_low, 0, - convert (type, integer_one_node), 0); + integer_one_node, 0); in_p = ! in_p; } else @@ -2960,17 +2965,21 @@ merge_ranges (pin_p, plow, phigh, in0_p, low0, high0, in1_p, low1, high1) { /* If they don't overlap, the result is the first range. If the second range is a subset of the first, we can't describe this as - a single range. Otherwise, we go from the start of the first - range to just before the start of the second. */ + a single range unless both ranges end at the same place, in which + case we can ignore the fact that it's a subset. Otherwise, we go + from the start of the first range to just before the start of the + second. */ if (no_overlap) in_p = 1, low = low0, high = high0; - else if (subset) + else if (subset + && integer_zerop (range_binop (EQ_EXPR, integer_type_node, + high0, 1, high1, 0))) return 0; else { in_p = 1, low = low0; high = range_binop (MINUS_EXPR, NULL_TREE, low1, 0, - integer_zero_node, 0); + integer_one_node, 0); } } |