diff options
author | Martin Liska <mliska@suse.cz> | 2022-11-08 12:36:43 +0100 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-11-08 12:36:43 +0100 |
commit | 4b13c73bba935443be3207abf26f7ba05f79badc (patch) | |
tree | a6bb1525d07859fa8fc6f61dd13df7ddfd1ac254 /gcc/range-op.cc | |
parent | 33f5dde0cd15df9cf89b29280d4ff5fcf7b30e66 (diff) | |
parent | fa271afb58423014e2feef9f15c1a87428e64ddc (diff) | |
download | gcc-devel/sphinx.tar.gz |
Merge branch 'master' into devel/sphinxdevel/sphinx
Diffstat (limited to 'gcc/range-op.cc')
-rw-r--r-- | gcc/range-op.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 5e94c3d2282..a13e88840a6 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); |