aboutsummaryrefslogtreecommitdiff
path: root/gcc/range-op.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/range-op.cc')
-rw-r--r--gcc/range-op.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 5e94c3d..a13e888 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -1911,8 +1911,20 @@ operator_mult::wi_fold (irange &r, tree type,
// diff = max - min
prod2 = prod3 - prod0;
if (wi::geu_p (prod2, sizem1))
- // The range covers all values.
- r.set_varying (type);
+ {
+ // Multiplying by X, where X is a power of 2 is [0,0][X,+INF].
+ if (TYPE_UNSIGNED (type) && rh_lb == rh_ub
+ && wi::exact_log2 (rh_lb) != -1 && prec > 1)
+ {
+ r.set (type, rh_lb, wi::max_value (prec, sign));
+ int_range<2> zero;
+ zero.set_zero (type);
+ r.union_ (zero);
+ }
+ else
+ // The range covers all values.
+ r.set_varying (type);
+ }
else
{
wide_int new_lb = wide_int::from (prod0, prec, sign);
@@ -1953,7 +1965,9 @@ operator_div::fold_range (irange &r, tree type,
return true;
tree t;
- if (rh.singleton_p (&t))
+ if (code == TRUNC_DIV_EXPR
+ && rh.singleton_p (&t)
+ && !wi::neg_p (lh.lower_bound ()))
{
wide_int wi = wi::to_wide (t);
int shift = wi::exact_log2 (wi);