diff mbox series

[COMMITTED] Remove value_range typedef.

Message ID 20240603125409.1537307-1-aldyh@redhat.com
State New
Headers show
Series [COMMITTED] Remove value_range typedef. | expand

Commit Message

Aldy Hernandez June 3, 2024, 12:54 p.m. UTC
Now that pointers and integers have been disambiguated from irange,
and all the pointer range temporaries use prange, we can reclaim
value_range as a general purpose range container.

This patch removes the typedef, in favor of int_range_max, thus
providing slightly better ranges in places.  I have also used
int_range<1> or <2> when it's known ahead of time how big the range will
be, thus saving a few words.

In a follow-up patch I will rename the Value_Range temporary to
value_range.

No change in performance.

gcc/ChangeLog:

	* builtins.cc (expand_builtin_strnlen): Replace value_range use
	with int_range_max or irange when appropriate.
	(determine_block_size): Same.
	* fold-const.cc (minmax_from_comparison): Same.
	* gimple-array-bounds.cc (check_out_of_bounds_and_warn): Same.
	(array_bounds_checker::check_array_ref): Same.
	* gimple-fold.cc (size_must_be_zero_p): Same.
	* gimple-predicate-analysis.cc (find_var_cmp_const): Same.
	* gimple-ssa-sprintf.cc (get_int_range): Same.
	(format_integer): Same.
	(try_substitute_return_value): Same.
	(handle_printf_call): Same.
	* gimple-ssa-warn-restrict.cc
	(builtin_memref::extend_offset_range): Same.
	* graphite-sese-to-poly.cc (add_param_constraints): Same.
	* internal-fn.cc (get_min_precision): Same.
	* match.pd: Same.
	* pointer-query.cc (get_size_range): Same.
	* range-op.cc (get_shift_range): Same.
	(operator_trunc_mod::op1_range): Same.
	(operator_trunc_mod::op2_range): Same.
	* range.cc (range_negatives): Same.
	* range.h (range_positives): Same.
	(range_negatives): Same.
	* tree-affine.cc (expr_to_aff_combination): Same.
	* tree-data-ref.cc (compute_distributive_range): Same.
	(nop_conversion_for_offset_p): Same.
	(split_constant_offset): Same.
	(split_constant_offset_1): Same.
	(dr_step_indicator): Same.
	* tree-dfa.cc (get_ref_base_and_extent): Same.
	* tree-scalar-evolution.cc (iv_can_overflow_p): Same.
	* tree-ssa-math-opts.cc (optimize_spaceship): Same.
	* tree-ssa-pre.cc (insert_into_preds_of_block): Same.
	* tree-ssa-reassoc.cc (optimize_range_tests_to_bit_test): Same.
	* tree-ssa-strlen.cc (compare_nonzero_chars): Same.
	(dump_strlen_info): Same.
	(get_range_strlen_dynamic): Same.
	(set_strlen_range): Same.
	(maybe_diag_stxncpy_trunc): Same.
	(strlen_pass::get_len_or_size): Same.
	(strlen_pass::handle_builtin_string_cmp): Same.
	(strlen_pass::count_nonzero_bytes_addr): Same.
	(strlen_pass::handle_integral_assign): Same.
	* tree-switch-conversion.cc (bit_test_cluster::emit): Same.
	* tree-vect-loop-manip.cc (vect_gen_vector_loop_niters): Same.
	(vect_do_peeling): Same.
	* tree-vect-patterns.cc (vect_get_range_info): Same.
	(vect_recog_divmod_pattern): Same.
	* tree.cc (get_range_pos_neg): Same.
	* value-range.cc (debug): Remove value_range variants.
	* value-range.h (value_range): Remove typedef.
	* vr-values.cc
	(simplify_using_ranges::op_with_boolean_value_range_p): Replace
	value_range use with int_range_max or irange when appropriate.
	(check_for_binary_op_overflow): Same.
	(simplify_using_ranges::legacy_fold_cond_overflow): Same.
	(find_case_label_ranges): Same.
	(simplify_using_ranges::simplify_abs_using_ranges): Same.
	(test_for_singularity): Same.
	(simplify_using_ranges::simplify_compare_using_ranges_1): Same.
	(simplify_using_ranges::simplify_casted_compare): Same.
	(simplify_using_ranges::simplify_switch_using_ranges): Same.
	(simplify_conversion_using_ranges): Same.
	(simplify_using_ranges::two_valued_val_range_p): Same.
---
 gcc/builtins.cc                  |  4 ++--
 gcc/fold-const.cc                |  4 ++--
 gcc/gimple-array-bounds.cc       |  4 ++--
 gcc/gimple-fold.cc               |  4 ++--
 gcc/gimple-predicate-analysis.cc |  2 +-
 gcc/gimple-ssa-sprintf.cc        |  8 +++----
 gcc/gimple-ssa-warn-restrict.cc  |  2 +-
 gcc/graphite-sese-to-poly.cc     |  2 +-
 gcc/internal-fn.cc               |  2 +-
 gcc/match.pd                     | 22 +++++++++---------
 gcc/pointer-query.cc             |  2 +-
 gcc/range-op.cc                  | 21 +++++++++---------
 gcc/range.cc                     | 10 ++++-----
 gcc/range.h                      |  4 ++--
 gcc/tree-affine.cc               |  2 +-
 gcc/tree-data-ref.cc             | 28 +++++++++++------------
 gcc/tree-dfa.cc                  |  2 +-
 gcc/tree-scalar-evolution.cc     |  2 +-
 gcc/tree-ssa-math-opts.cc        |  2 +-
 gcc/tree-ssa-pre.cc              |  2 +-
 gcc/tree-ssa-reassoc.cc          |  2 +-
 gcc/tree-ssa-strlen.cc           | 22 +++++++++---------
 gcc/tree-switch-conversion.cc    |  2 +-
 gcc/tree-vect-loop-manip.cc      | 32 +++++++++++++--------------
 gcc/tree-vect-patterns.cc        |  4 ++--
 gcc/tree.cc                      |  2 +-
 gcc/value-range.cc               | 14 ------------
 gcc/value-range.h                |  2 --
 gcc/vr-values.cc                 | 38 ++++++++++++++++----------------
 29 files changed, 115 insertions(+), 132 deletions(-)
diff mbox series

Patch

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index f8d94c4b435..00ee9eb2925 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -3502,7 +3502,7 @@  expand_builtin_strnlen (tree exp, rtx target, machine_mode target_mode)
     return NULL_RTX;
 
   wide_int min, max;
-  value_range r;
+  int_range_max r;
   get_global_range_query ()->range_of_expr (r, bound);
   if (r.varying_p () || r.undefined_p ())
     return NULL_RTX;
@@ -3576,7 +3576,7 @@  determine_block_size (tree len, rtx len_rtx,
 
       if (TREE_CODE (len) == SSA_NAME)
 	{
-	  value_range r;
+	  int_range_max r;
 	  tree tmin, tmax;
 	  get_global_range_query ()->range_of_expr (r, len);
 	  range_type = get_legacy_range (r, tmin, tmax);
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 7b268964acc..117a816fec6 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -177,7 +177,7 @@  minmax_from_comparison (tree_code cmp, tree exp0, tree exp1, tree exp2, tree exp
 	  /* a != MIN_RANGE<a> ? a : MIN_RANGE<a>+1 -> MAX_EXPR<MIN_RANGE<a>+1, a> */
 	  if (cmp == NE_EXPR && TREE_CODE (exp0) == SSA_NAME)
 	    {
-	      value_range r;
+	      int_range_max r;
 	      get_range_query (cfun)->range_of_expr (r, exp0);
 	      if (r.undefined_p ())
 		r.set_varying (TREE_TYPE (exp0));
@@ -199,7 +199,7 @@  minmax_from_comparison (tree_code cmp, tree exp0, tree exp1, tree exp2, tree exp
 	  /* a != MAX_RANGE<a> ? a : MAX_RANGE<a>-1 -> MIN_EXPR<MIN_RANGE<a>-1, a> */
 	  if (cmp == NE_EXPR && TREE_CODE (exp0) == SSA_NAME)
 	    {
-	      value_range r;
+	      int_range_max r;
 	      get_range_query (cfun)->range_of_expr (r, exp0);
 	      if (r.undefined_p ())
 		r.set_varying (TREE_TYPE (exp0));
diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc
index 008071cd546..2fa3d18d295 100644
--- a/gcc/gimple-array-bounds.cc
+++ b/gcc/gimple-array-bounds.cc
@@ -262,7 +262,7 @@  static bool
 check_out_of_bounds_and_warn (location_t location, tree ref,
 			      tree low_sub_org, tree low_sub, tree up_sub,
 			      tree up_bound, tree up_bound_p1,
-			      const value_range *vr,
+			      const irange *vr,
 			      bool ignore_off_by_one, bool for_array_bound,
 			      bool *out_of_bound)
 {
@@ -373,7 +373,7 @@  array_bounds_checker::check_array_ref (location_t location, tree ref,
   tree up_sub = low_sub_org;
   tree low_sub = low_sub_org;
 
-  value_range vr;
+  int_range_max vr;
   if (TREE_CODE (low_sub_org) == SSA_NAME)
     {
       get_value_range (vr, low_sub_org, stmt);
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index d2a0f6ddf19..c33583cf3ee 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -874,8 +874,8 @@  size_must_be_zero_p (tree size)
      can be stored in ssize_t, the signed counterpart of size_t.  */
   wide_int ssize_max = wi::lshift (wi::one (prec), prec - 1) - 1;
   wide_int zero = wi::zero (TYPE_PRECISION (type));
-  value_range valid_range (type, zero, ssize_max);
-  value_range vr;
+  int_range_max valid_range (type, zero, ssize_max);
+  int_range_max vr;
   get_range_query (cfun)->range_of_expr (vr, size);
 
   if (vr.undefined_p ())
diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
index 8c28c76cf0e..01688b8581b 100644
--- a/gcc/gimple-predicate-analysis.cc
+++ b/gcc/gimple-predicate-analysis.cc
@@ -300,7 +300,7 @@  find_var_cmp_const (pred_chain_union preds, gphi *phi, gimple **flag_def,
 	       flag_var >= [min, max] ->  flag_var > [min-1, max]
 	     if no overflow/wrap.  */
 	  tree type = TREE_TYPE (cond_lhs);
-	  value_range r;
+	  int_range_max r;
 	  if (!INTEGRAL_TYPE_P (type)
 	      || !get_range_query (cfun)->range_of_expr (r, cond_rhs)
 	      || r.undefined_p ()
diff --git a/gcc/gimple-ssa-sprintf.cc b/gcc/gimple-ssa-sprintf.cc
index 3b19f4d3f35..025b0fbff6f 100644
--- a/gcc/gimple-ssa-sprintf.cc
+++ b/gcc/gimple-ssa-sprintf.cc
@@ -1079,7 +1079,7 @@  get_int_range (tree arg, gimple *stmt,
 	  && TYPE_PRECISION (argtype) <= TYPE_PRECISION (type))
 	{
 	  /* Try to determine the range of values of the integer argument.  */
-	  value_range vr;
+	  int_range_max vr;
 	  query->range_of_expr (vr, arg, stmt);
 
 	  if (!vr.undefined_p () && !vr.varying_p ())
@@ -1395,7 +1395,7 @@  format_integer (const directive &dir, tree arg, pointer_query &ptr_qry)
     {
       /* Try to determine the range of values of the integer argument
 	 (range information is not available for pointers).  */
-      value_range vr;
+      int_range_max vr;
       ptr_qry.rvals->range_of_expr (vr, arg, dir.info->callstmt);
 
       if (!vr.varying_p () && !vr.undefined_p ())
@@ -4260,7 +4260,7 @@  try_substitute_return_value (gimple_stmt_iterator *gsi,
 
 	  wide_int min = wi::shwi (retval[0], prec);
 	  wide_int max = wi::shwi (retval[1], prec);
-	  value_range r (TREE_TYPE (lhs), min, max);
+	  int_range_max r (TREE_TYPE (lhs), min, max);
 	  set_range_info (lhs, r);
 
 	  setrange = true;
@@ -4629,7 +4629,7 @@  handle_printf_call (gimple_stmt_iterator *gsi, pointer_query &ptr_qry)
 	  /* Try to determine the range of values of the argument
 	     and use the greater of the two at level 1 and the smaller
 	     of them at level 2.  */
-	  value_range vr;
+	  int_range_max vr;
 	  ptr_qry.rvals->range_of_expr (vr, size, info.callstmt);
 
 	  if (!vr.undefined_p ())
diff --git a/gcc/gimple-ssa-warn-restrict.cc b/gcc/gimple-ssa-warn-restrict.cc
index a552ce8dcdf..d71f1331c85 100644
--- a/gcc/gimple-ssa-warn-restrict.cc
+++ b/gcc/gimple-ssa-warn-restrict.cc
@@ -352,7 +352,7 @@  builtin_memref::extend_offset_range (tree offset)
 	 as signed.  */
       wide_int min, max;
       value_range_kind rng = VR_VARYING;
-      value_range vr;
+      int_range_max vr;
       if (m_ptr_qry.rvals->range_of_expr (vr, offset, stmt))
 	{
 	  tree vr_min, vr_max;
diff --git a/gcc/graphite-sese-to-poly.cc b/gcc/graphite-sese-to-poly.cc
index 4f614a3ba82..5ce898505a3 100644
--- a/gcc/graphite-sese-to-poly.cc
+++ b/gcc/graphite-sese-to-poly.cc
@@ -420,7 +420,7 @@  static void
 add_param_constraints (scop_p scop, graphite_dim_t p, tree parameter)
 {
   tree type = TREE_TYPE (parameter);
-  value_range r;
+  int_range_max r;
   wide_int min, max;
 
   gcc_assert (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type));
diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 0d27f17b283..4948b48bde8 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -893,7 +893,7 @@  get_min_precision (tree arg, signop sign)
     }
   if (TREE_CODE (arg) != SSA_NAME)
     return prec + (orig_sign != sign);
-  value_range r;
+  int_range_max r;
   while (!get_global_range_query ()->range_of_expr (r, arg)
 	 || r.varying_p ()
 	 || r.undefined_p ())
diff --git a/gcc/match.pd b/gcc/match.pd
index 480e36bbbaf..f19ef702747 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -633,7 +633,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   if (TYPE_OVERFLOW_UNDEFINED (type))
     {
 #if GIMPLE
-      value_range vr0;
+      int_range_max vr0;
       if (ovf1 == wi::OVF_NONE && ovf2 == wi::OVF_NONE
 	  && get_global_range_query ()->range_of_expr (vr0, @4)
 	  && !vr0.varying_p () && !vr0.undefined_p ())
@@ -674,7 +674,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   if (TYPE_OVERFLOW_UNDEFINED (type))
     {
 #if GIMPLE
-      value_range vr0;
+      int_range_max vr0;
       if (ovf1 == wi::OVF_NONE && ovf2 == wi::OVF_NONE
 	  && get_global_range_query ()->range_of_expr (vr0, @0)
 	  && !vr0.varying_p () && !vr0.undefined_p ())
@@ -957,7 +957,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (if (TYPE_OVERFLOW_UNDEFINED (type) && !TYPE_OVERFLOW_SANITIZED (type))
     @0
 #if GIMPLE
-    (with {value_range vr0, vr1;}
+    (with {int_range_max vr0, vr1;}
      (if (INTEGRAL_TYPE_P (type)
 	  && get_range_query (cfun)->range_of_expr (vr0, @0)
 	  && get_range_query (cfun)->range_of_expr (vr1, @1)
@@ -973,7 +973,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        && wi::multiple_of_p (wi::to_widest (@1), wi::to_widest (@2), SIGNED))
    (if (TYPE_OVERFLOW_UNDEFINED (type) && !TYPE_OVERFLOW_SANITIZED (type))
     (mult @0 (div! @1 @2))
-    (with {value_range vr0, vr1;}
+    (with {int_range_max vr0, vr1;}
      (if (get_range_query (cfun)->range_of_expr (vr0, @0)
 	  && get_range_query (cfun)->range_of_expr (vr1, @1)
 	  && range_op_handler (MULT_EXPR).overflow_free_p (vr0, vr1))
@@ -988,7 +988,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (if (TYPE_OVERFLOW_UNDEFINED (type) && !TYPE_OVERFLOW_SANITIZED (type))
     (div @1 @2)
 #if GIMPLE
-    (with {value_range vr0, vr1, vr2;}
+    (with {int_range_max vr0, vr1, vr2;}
      (if (get_range_query (cfun)->range_of_expr (vr0, @0)
 	  && get_range_query (cfun)->range_of_expr (vr1, @1)
 	  && get_range_query (cfun)->range_of_expr (vr2, @2)
@@ -1003,7 +1003,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  /* Simplify (X + M*N) / N -> X / N + M.  */
  (simplify
   (div (plus:c@4 @0 (mult:c@3 @1 @2)) @2)
-  (with {value_range vr0, vr1, vr2, vr3, vr4;}
+  (with {int_range_max vr0, vr1, vr2, vr3, vr4;}
   (if (INTEGRAL_TYPE_P (type)
        && get_range_query (cfun)->range_of_expr (vr1, @1)
        && get_range_query (cfun)->range_of_expr (vr2, @2)
@@ -1024,7 +1024,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  /* Simplify (X - M*N) / N -> X / N - M.  */
  (simplify
   (div (minus@4 @0 (mult:c@3 @1 @2)) @2)
-  (with {value_range vr0, vr1, vr2, vr3, vr4;}
+  (with {int_range_max vr0, vr1, vr2, vr3, vr4;}
   (if (INTEGRAL_TYPE_P (type)
        && get_range_query (cfun)->range_of_expr (vr1, @1)
        && get_range_query (cfun)->range_of_expr (vr2, @2)
@@ -1057,7 +1057,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 			   : wi::div_trunc (v, n, TYPE_SIGN (type)))
 #define exact_mod(v) (shift ? wi::ctz (v) >= n.to_shwi () \
 			    : wi::multiple_of_p (v, n, TYPE_SIGN (type)))
-      value_range vr0, vr1, vr3;
+      int_range_max vr0, vr1, vr3;
     }
     (if (INTEGRAL_TYPE_P (type)
 	 && get_range_query (cfun)->range_of_expr (vr0, @0))
@@ -2867,7 +2867,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    { constant_boolean_node (cmp == NE_EXPR, type); })))
 
 /* ((X inner_op C0) outer_op C1)
-   With X being a tree where value_range has reasoned certain bits to always be
+   With X being a tree where range has reasoned certain bits to always be
    zero throughout its computed value range,
    inner_op = {|,^}, outer_op = {|,^} and inner_op != outer_op
    where zero_mask has 1's for all bits that are sure to be 0 in
@@ -3674,7 +3674,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 	  = wide_int::from (wi::to_wide (@1), TYPE_PRECISION (inner_type),
 			    TYPE_SIGN (inner_type));
 
-	value_range vr;
+	int_range_max vr;
 	if (get_global_range_query ()->range_of_expr (vr, @0)
 	    && !vr.varying_p () && !vr.undefined_p ())
           {
@@ -5520,7 +5520,7 @@  DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        && (wi::to_widest (@2) + 1 == wi::to_widest (@3)
            || wi::to_widest (@2) == wi::to_widest (@3) + 1))
    (with {
-     value_range r;
+     int_range_max r;
      get_range_query (cfun)->range_of_expr (r, @0);
      if (r.undefined_p ())
        r.set_varying (TREE_TYPE (@0));
diff --git a/gcc/pointer-query.cc b/gcc/pointer-query.cc
index ccf9d823870..c8ab0571e57 100644
--- a/gcc/pointer-query.cc
+++ b/gcc/pointer-query.cc
@@ -316,7 +316,7 @@  get_size_range (range_query *query, tree exp, gimple *stmt, tree range[2],
 
   if (integral)
     {
-      value_range vr;
+      int_range_max vr;
       tree tmin, tmax;
 
       query->range_of_expr (vr, exp, stmt);
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index d188d1a1b63..c576f688221 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -570,9 +570,9 @@  get_shift_range (irange &r, tree type, const irange &op)
     return false;
 
   // Build valid range and intersect it with the shift range.
-  r = value_range (op.type (),
-		   wi::shwi (0, TYPE_PRECISION (op.type ())),
-		   wi::shwi (TYPE_PRECISION (type) - 1, TYPE_PRECISION (op.type ())));
+  r.set (op.type (),
+	 wi::shwi (0, TYPE_PRECISION (op.type ())),
+	 wi::shwi (TYPE_PRECISION (type) - 1, TYPE_PRECISION (op.type ())));
   r.intersect (op);
 
   // If there are no valid ranges in the shift range, returned false.
@@ -4055,13 +4055,13 @@  operator_trunc_mod::op1_range (irange &r, tree type,
   // (a % b) >= x && x > 0 , then a >= x.
   if (wi::gt_p (lhs.lower_bound (), 0, sign))
     {
-      r = value_range (type, lhs.lower_bound (), wi::max_value (prec, sign));
+      r.set (type, lhs.lower_bound (), wi::max_value (prec, sign));
       return true;
     }
   // (a % b) <= x && x < 0 , then a <= x.
   if (wi::lt_p (lhs.upper_bound (), 0, sign))
     {
-      r = value_range (type, wi::min_value (prec, sign), lhs.upper_bound ());
+      r.set (type, wi::min_value (prec, sign), lhs.upper_bound ());
       return true;
     }
   return false;
@@ -4083,12 +4083,11 @@  operator_trunc_mod::op2_range (irange &r, tree type,
   if (wi::gt_p (lhs.lower_bound (), 0, sign))
     {
       if (sign == SIGNED)
-	r = value_range (type, wi::neg (lhs.lower_bound ()),
-			 lhs.lower_bound (), VR_ANTI_RANGE);
+	r.set (type, wi::neg (lhs.lower_bound ()),
+	       lhs.lower_bound (), VR_ANTI_RANGE);
       else if (wi::lt_p (lhs.lower_bound (), wi::max_value (prec, sign),
 			 sign))
-	r = value_range (type, lhs.lower_bound () + 1,
-			 wi::max_value (prec, sign));
+	r.set (type, lhs.lower_bound () + 1, wi::max_value (prec, sign));
       else
 	return false;
       return true;
@@ -4097,8 +4096,8 @@  operator_trunc_mod::op2_range (irange &r, tree type,
   if (wi::lt_p (lhs.upper_bound (), 0, sign))
     {
       if (wi::gt_p (lhs.upper_bound (), wi::min_value (prec, sign), sign))
-	r = value_range (type, lhs.upper_bound (),
-			 wi::neg (lhs.upper_bound ()), VR_ANTI_RANGE);
+	r.set (type, lhs.upper_bound (),
+	       wi::neg (lhs.upper_bound ()), VR_ANTI_RANGE);
       else
 	return false;
       return true;
diff --git a/gcc/range.cc b/gcc/range.cc
index b362e0f12e0..5ee0edc54f6 100644
--- a/gcc/range.cc
+++ b/gcc/range.cc
@@ -29,23 +29,23 @@  along with GCC; see the file COPYING3.  If not see
 #include "ssa.h"
 #include "range.h"
 
-value_range
+int_range<2>
 range_positives (tree type)
 {
   unsigned prec = TYPE_PRECISION (type);
   signop sign = TYPE_SIGN (type);
-  return value_range (type, wi::zero (prec), wi::max_value (prec, sign));
+  return int_range<2> (type, wi::zero (prec), wi::max_value (prec, sign));
 }
 
-value_range
+int_range<2>
 range_negatives (tree type)
 {
   unsigned prec = TYPE_PRECISION (type);
   signop sign = TYPE_SIGN (type);
-  value_range r;
+  int_range<2> r;
   if (sign == UNSIGNED)
     r.set_undefined ();
   else
-    r = value_range (type, wi::min_value (prec, sign), wi::minus_one (prec));
+    r.set (type, wi::min_value (prec, sign), wi::minus_one (prec));
   return r;
 }
diff --git a/gcc/range.h b/gcc/range.h
index eccb9490e4d..e98dc2390a6 100644
--- a/gcc/range.h
+++ b/gcc/range.h
@@ -21,8 +21,8 @@  along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_RANGE_H
 #define GCC_RANGE_H
 
-value_range range_positives (tree type);
-value_range range_negatives (tree type);
+int_range<2> range_positives (tree type);
+int_range<2> range_negatives (tree type);
 
 // Return an irange instance that is a boolean TRUE.
 
diff --git a/gcc/tree-affine.cc b/gcc/tree-affine.cc
index 3941a7700b1..d6309c43903 100644
--- a/gcc/tree-affine.cc
+++ b/gcc/tree-affine.cc
@@ -345,7 +345,7 @@  expr_to_aff_combination (aff_tree *comb, tree_code code, tree type,
 	       for below case:
 		 (T1)(X *+- CST) -> (T1)X *+- (T1)CST
 	       if X *+- CST doesn't overflow by range information.  */
-	    value_range vr;
+	    int_range_max vr;
 	    if (TYPE_UNSIGNED (itype)
 		&& TYPE_OVERFLOW_WRAPS (itype)
 		&& TREE_CODE (op1) == INTEGER_CST
diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index 7c4049faf34..7b5f2d16238 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -588,9 +588,9 @@  debug_ddrs (vec<ddr_p> ddrs)
    precision of A and B.  */
 
 static bool
-compute_distributive_range (tree type, value_range &op0_range,
-			    tree_code code, value_range &op1_range,
-			    tree *off, value_range *result_range)
+compute_distributive_range (tree type, irange &op0_range,
+			    tree_code code, irange &op1_range,
+			    tree *off, irange *result_range)
 {
   gcc_assert (INTEGRAL_TYPE_P (type) && !TYPE_OVERFLOW_TRAPS (type));
   if (result_range)
@@ -641,7 +641,7 @@  compute_distributive_range (tree type, value_range &op0_range,
      but its range is more conducive to analysis.  */
   range_cast (op0_range, ssizetype);
   range_cast (op1_range, ssizetype);
-  value_range wide_range;
+  int_range_max wide_range;
   range_op_handler op (code);
   bool saved_flag_wrapv = flag_wrapv;
   flag_wrapv = 1;
@@ -682,7 +682,7 @@  compute_distributive_range (tree type, value_range &op0_range,
    FROM_TYPE are integral types.  */
 
 static bool
-nop_conversion_for_offset_p (tree to_type, tree from_type, value_range &range)
+nop_conversion_for_offset_p (tree to_type, tree from_type, irange &range)
 {
   gcc_assert (INTEGRAL_TYPE_P (to_type)
 	      && INTEGRAL_TYPE_P (from_type)
@@ -714,7 +714,7 @@  nop_conversion_for_offset_p (tree to_type, tree from_type, value_range &range)
 
 static void
 split_constant_offset (tree type, tree *var, tree *off,
-		       value_range *result_range,
+		       irange *result_range,
 		       hash_map<tree, std::pair<tree, tree> > &cache,
 		       unsigned *limit);
 
@@ -751,13 +751,13 @@  split_constant_offset (tree type, tree *var, tree *off,
 
 static bool
 split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1,
-			 tree *var, tree *off, value_range *result_range,
+			 tree *var, tree *off, irange *result_range,
 			 hash_map<tree, std::pair<tree, tree> > &cache,
 			 unsigned *limit)
 {
   tree var0, var1;
   tree off0, off1;
-  value_range op0_range, op1_range;
+  int_range_max op0_range, op1_range;
 
   *var = NULL_TREE;
   *off = NULL_TREE;
@@ -1013,7 +1013,7 @@  split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1,
    allowed to process before giving up.  */
 
 static void
-split_constant_offset (tree exp, tree *var, tree *off, value_range *exp_range,
+split_constant_offset (tree exp, tree *var, tree *off, irange *exp_range,
 		       hash_map<tree, std::pair<tree, tree> > &cache,
 		       unsigned *limit)
 {
@@ -1023,10 +1023,10 @@  split_constant_offset (tree exp, tree *var, tree *off, value_range *exp_range,
   code = TREE_CODE (exp);
   if (exp_range)
     {
-      *exp_range = type;
+      exp_range->set_varying (type);
       if (code == SSA_NAME)
 	{
-	  value_range vr;
+	  int_range_max vr;
 	  get_range_query (cfun)->range_of_expr (vr, exp);
 	  if (vr.undefined_p ())
 	    vr.set_varying (TREE_TYPE (exp));
@@ -1044,7 +1044,7 @@  split_constant_offset (tree exp, tree *var, tree *off, value_range *exp_range,
 	     domain, instead of VR_VARYING.  The new code normalizes
 	     full-domain ranges to VR_VARYING.  */
 	  if (vr_kind == VR_RANGE || vr_kind == VR_VARYING)
-	    *exp_range = value_range (type, var_min, var_max);
+	    exp_range->set (type, var_min, var_max);
 	}
     }
 
@@ -1062,7 +1062,7 @@  split_constant_offset (tree exp, tree *var, tree *off, value_range *exp_range,
     *var = fold_convert (sizetype, *var);
   *off = ssize_int (0);
 
-  value_range r;
+  int_range_max r;
   if (exp_range && code != SSA_NAME
       && get_range_query (cfun)->range_of_expr (r, exp)
       && !r.undefined_p ())
@@ -6402,7 +6402,7 @@  dr_step_indicator (struct data_reference *dr, int useful_min)
 
       /* Get the range of values that the unconverted step actually has.  */
       wide_int step_min, step_max;
-      value_range vr;
+      int_range_max vr;
       if (TREE_CODE (step) != SSA_NAME
 	  || !get_range_query (cfun)->range_of_expr (vr, step)
 	  || vr.undefined_p ())
diff --git a/gcc/tree-dfa.cc b/gcc/tree-dfa.cc
index 93e53b29a6d..77e119a6b1b 100644
--- a/gcc/tree-dfa.cc
+++ b/gcc/tree-dfa.cc
@@ -530,7 +530,7 @@  get_ref_base_and_extent (tree exp, poly_int64 *poffset,
 		   index.  */
 		seen_variable_array_ref = true;
 
-		value_range vr;
+		int_range_max vr;
 		range_query *query;
 		query = get_range_query (cfun);
 
diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc
index 622c7246c1b..5aa95a2497a 100644
--- a/gcc/tree-scalar-evolution.cc
+++ b/gcc/tree-scalar-evolution.cc
@@ -3057,7 +3057,7 @@  iv_can_overflow_p (class loop *loop, tree type, tree base, tree step)
   widest_int nit;
   wide_int base_min, base_max, step_min, step_max, type_min, type_max;
   signop sgn = TYPE_SIGN (type);
-  value_range r;
+  int_range_max r;
 
   if (integer_zerop (step))
     return false;
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 62da1c5ee08..57d51fd01ee 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -5956,7 +5956,7 @@  optimize_spaceship (gcond *stmt)
 
   wide_int wm1 = wi::minus_one (TYPE_PRECISION (integer_type_node));
   wide_int w2 = wi::two (TYPE_PRECISION (integer_type_node));
-  value_range vr (TREE_TYPE (lhs), wm1, w2);
+  int_range<1> vr (TREE_TYPE (lhs), wm1, w2);
   set_range_info (lhs, vr);
 }
 
diff --git a/gcc/tree-ssa-pre.cc b/gcc/tree-ssa-pre.cc
index 5cf1968bc26..6c0436b8b15 100644
--- a/gcc/tree-ssa-pre.cc
+++ b/gcc/tree-ssa-pre.cc
@@ -3251,7 +3251,7 @@  insert_into_preds_of_block (basic_block block, unsigned int exprnum,
 	  >= TYPE_PRECISION (TREE_TYPE (expr->u.nary->op[0])))
       && SSA_NAME_RANGE_INFO (expr->u.nary->op[0]))
     {
-      value_range r;
+      int_range_max r;
       if (get_range_query (cfun)->range_of_expr (r, expr->u.nary->op[0])
 	  && !r.undefined_p ()
 	  && !r.varying_p ()
diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc
index 556ecdebe2d..4d9f5216d4c 100644
--- a/gcc/tree-ssa-reassoc.cc
+++ b/gcc/tree-ssa-reassoc.cc
@@ -3377,7 +3377,7 @@  optimize_range_tests_to_bit_test (enum tree_code opcode, int first, int length,
 	 case, if we would need otherwise 2 or more comparisons, then use
 	 the bit test; in the other cases, the threshold is 3 comparisons.  */
       bool entry_test_needed;
-      value_range r;
+      int_range_max r;
       if (TREE_CODE (exp) == SSA_NAME
 	  && get_range_query (cfun)->range_of_expr (r, exp)
 	  && !r.undefined_p ()
diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc
index c43a2da2836..d3c7dc3a80f 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -347,7 +347,7 @@  compare_nonzero_chars (strinfo *si, gimple *stmt,
   if (!rvals || TREE_CODE (si->nonzero_chars) != SSA_NAME)
     return -1;
 
-  value_range vr;
+  int_range_max vr;
   if (!rvals->range_of_expr (vr, si->nonzero_chars, stmt)
       || vr.varying_p ()
       || vr.undefined_p ())
@@ -980,7 +980,7 @@  dump_strlen_info (FILE *fp, gimple *stmt, range_query *rvals)
 		  print_generic_expr (fp, si->nonzero_chars);
 		  if (TREE_CODE (si->nonzero_chars) == SSA_NAME)
 		    {
-		      value_range vr;
+		      int_range_max vr;
 		      if (rvals)
 			rvals->range_of_expr (vr, si->nonzero_chars,
 					      si->stmt);
@@ -1218,7 +1218,7 @@  get_range_strlen_dynamic (tree src, gimple *stmt,
 	    pdata->minlen = si->nonzero_chars;
 	  else if (TREE_CODE (si->nonzero_chars) == SSA_NAME)
 	    {
-	      value_range vr;
+	      int_range_max vr;
 	      ptr_qry->rvals->range_of_expr (vr, si->nonzero_chars, si->stmt);
 	      if (vr.undefined_p () || vr.varying_p ())
 		pdata->minlen = build_zero_cst (size_type_node);
@@ -1274,7 +1274,7 @@  get_range_strlen_dynamic (tree src, gimple *stmt,
 	}
       else if (pdata->minlen && TREE_CODE (pdata->minlen) == SSA_NAME)
 	{
-	  value_range vr;
+	  int_range_max vr;
 	  ptr_qry->rvals->range_of_expr (vr, si->nonzero_chars, stmt);
 	  if (vr.varying_p () || vr.undefined_p ())
 	    {
@@ -1919,7 +1919,7 @@  set_strlen_range (tree lhs, wide_int min, wide_int max,
 	}
       else if (TREE_CODE (bound) == SSA_NAME)
 	{
-	  value_range r;
+	  int_range_max r;
 	  get_range_query (cfun)->range_of_expr (r, bound);
 	  if (!r.undefined_p ())
 	    {
@@ -1937,7 +1937,7 @@  set_strlen_range (tree lhs, wide_int min, wide_int max,
   if (min == max)
     return wide_int_to_tree (size_type_node, min);
 
-  value_range vr (TREE_TYPE (lhs), min, max);
+  int_range_max vr (TREE_TYPE (lhs), min, max);
   set_range_info (lhs, vr);
   return lhs;
 }
@@ -2900,7 +2900,7 @@  maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt,
     return false;
 
   wide_int cntrange[2];
-  value_range r;
+  int_range_max r;
   if (!get_range_query (cfun)->range_of_expr (r, cnt)
       || r.varying_p ()
       || r.undefined_p ())
@@ -4075,7 +4075,7 @@  strlen_pass::get_len_or_size (gimple *stmt, tree arg, int idx,
 	}
       else if (TREE_CODE (si->nonzero_chars) == SSA_NAME)
 	{
-	  value_range r;
+	  int_range_max r;
 	  if (get_range_query (cfun)->range_of_expr (r, si->nonzero_chars)
 	      && !r.undefined_p ()
 	      && !r.varying_p ())
@@ -4370,7 +4370,7 @@  strlen_pass::handle_builtin_string_cmp ()
 	       known to be unequal set the range of the result to non-zero.
 	       This allows the call to be eliminated if its result is only
 	       used in tests for equality to zero.  */
-	    value_range nz;
+	    int_range_max nz;
 	    nz.set_nonzero (TREE_TYPE (lhs));
 	    set_range_info (lhs, nz);
 	    return false;
@@ -4807,7 +4807,7 @@  strlen_pass::count_nonzero_bytes_addr (tree exp, tree vuse, gimple *stmt,
       else if (si->nonzero_chars
 	       && TREE_CODE (si->nonzero_chars) == SSA_NAME)
 	{
-	  value_range vr;
+	  int_range_max vr;
 	  if (!ptr_qry.rvals->range_of_expr (vr, si->nonzero_chars, stmt)
 	      || vr.undefined_p ()
 	      || vr.varying_p ())
@@ -5567,7 +5567,7 @@  strlen_pass::handle_integral_assign (bool *cleanup_eh)
 		  /* Reading a character before the final '\0'
 		     character.  Just set the value range to ~[0, 0]
 		     if we don't have anything better.  */
-		  value_range r;
+		  int_range_max r;
 		  if (!get_range_query (cfun)->range_of_expr (r, lhs)
 		      || r.varying_p ())
 		    {
diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
index 3a5b84c09e2..64629122ec6 100644
--- a/gcc/tree-switch-conversion.cc
+++ b/gcc/tree-switch-conversion.cc
@@ -1662,7 +1662,7 @@  bit_test_cluster::emit (tree index_expr, tree index_type,
   /* If every possible relative value of the index expression is a valid shift
      amount, then we can merge the entry test in the bit test.  */
   bool entry_test_needed;
-  value_range r;
+  int_range_max r;
   if (TREE_CODE (index_expr) == SSA_NAME
       && get_range_query (cfun)->range_of_expr (r, index_expr)
       && !r.undefined_p ()
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc
index 43c7881c640..ac13873cd88 100644
--- a/gcc/tree-vect-loop-manip.cc
+++ b/gcc/tree-vect-loop-manip.cc
@@ -2845,25 +2845,25 @@  vect_gen_vector_loop_niters (loop_vec_info loop_vinfo, tree niters,
 	{
 	  if (niters_no_overflow)
 	    {
-	      value_range vr (type,
-			      wi::one (TYPE_PRECISION (type)),
-			      wi::rshift (wi::max_value (TYPE_PRECISION (type),
-							 TYPE_SIGN (type)),
-					  exact_log2 (const_vf),
-					  TYPE_SIGN (type)));
+	      int_range<1> vr (type,
+			       wi::one (TYPE_PRECISION (type)),
+			       wi::rshift (wi::max_value (TYPE_PRECISION (type),
+							  TYPE_SIGN (type)),
+					   exact_log2 (const_vf),
+					   TYPE_SIGN (type)));
 	      set_range_info (niters_vector, vr);
 	    }
 	  /* For VF == 1 the vector IV might also overflow so we cannot
 	     assert a minimum value of 1.  */
 	  else if (const_vf > 1)
 	    {
-	      value_range vr (type,
-			      wi::one (TYPE_PRECISION (type)),
-			      wi::rshift (wi::max_value (TYPE_PRECISION (type),
-							 TYPE_SIGN (type))
-					  - (const_vf - 1),
-					  exact_log2 (const_vf), TYPE_SIGN (type))
-			      + 1);
+	      int_range<1> vr (type,
+			       wi::one (TYPE_PRECISION (type)),
+			       wi::rshift (wi::max_value (TYPE_PRECISION (type),
+							  TYPE_SIGN (type))
+					   - (const_vf - 1),
+					   exact_log2 (const_vf), TYPE_SIGN (type))
+			       + 1);
 	      set_range_info (niters_vector, vr);
 	    }
 	}
@@ -3408,9 +3408,9 @@  vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
 	 least VF, so set range information for newly generated var.  */
       if (new_var_p)
 	{
-	  value_range vr (type,
-			  wi::to_wide (build_int_cst (type, lowest_vf)),
-			  wi::to_wide (TYPE_MAX_VALUE (type)));
+	  int_range<1> vr (type,
+			   wi::to_wide (build_int_cst (type, lowest_vf)),
+			   wi::to_wide (TYPE_MAX_VALUE (type)));
 	  set_range_info (niters, vr);
 	}
 
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 88e7e34d78d..81e8fdc9122 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -66,7 +66,7 @@  along with GCC; see the file COPYING3.  If not see
 bool
 vect_get_range_info (tree var, wide_int *min_value, wide_int *max_value)
 {
-  value_range vr;
+  int_range_max vr;
   tree vr_min, vr_max;
   get_range_query (cfun)->range_of_expr (vr, var);
   if (vr.undefined_p ())
@@ -5011,7 +5011,7 @@  vect_recog_divmod_pattern (vec_info *vinfo,
 	t3 = t2;
 
       int msb = 1;
-      value_range r;
+      int_range_max r;
       get_range_query (cfun)->range_of_expr (r, oprnd0);
       if (!r.varying_p () && !r.undefined_p ())
 	{
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 01572fe70f7..209ea7f8f46 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -14495,7 +14495,7 @@  get_range_pos_neg (tree arg)
 
   if (TREE_CODE (arg) != SSA_NAME)
     return 3;
-  value_range r;
+  int_range_max r;
   while (!get_global_range_query ()->range_of_expr (r, arg)
 	 || r.undefined_p () || r.varying_p ())
     {
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index b38d6159a85..dbb4f81ae3c 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -2506,20 +2506,6 @@  debug (const vrange &vr)
   debug (&vr);
 }
 
-DEBUG_FUNCTION void
-debug (const value_range *vr)
-{
-  dump_value_range (stderr, vr);
-  fprintf (stderr, "\n");
-}
-
-DEBUG_FUNCTION void
-debug (const value_range &vr)
-{
-  dump_value_range (stderr, &vr);
-  fprintf (stderr, "\n");
-}
-
 /* Return true, if VAL1 and VAL2 are equal values for VRP purposes.  */
 
 bool
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 44cdbd717f4..3cc15d51516 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -739,8 +739,6 @@  public:
   virtual void visit (const unsupported_range &) const { }
 };
 
-typedef int_range<2> value_range;
-
 // This is an "infinite" precision range object for use in temporary
 // calculations for any of the handled types.  The object can be
 // transparently used as a vrange.
diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc
index e6ea9592574..470e3145787 100644
--- a/gcc/vr-values.cc
+++ b/gcc/vr-values.cc
@@ -69,7 +69,7 @@  simplify_using_ranges::op_with_boolean_value_range_p (tree op, gimple *s)
 
   /* ?? Errr, this should probably check for [0,0] and [1,1] as well
      as [0,1].  */
-  value_range vr;
+  int_range_max vr;
   return (query->range_of_expr (vr, op, s)
 	  && vr == range_true_and_false (TREE_TYPE (op)));
 }
@@ -85,7 +85,7 @@  check_for_binary_op_overflow (range_query *query,
 			      enum tree_code subcode, tree type,
 			      tree op0, tree op1, bool *ovf, gimple *s = NULL)
 {
-  value_range vr0, vr1;
+  int_range_max vr0, vr1;
   if (!query->range_of_expr (vr0, op0, s) || vr0.undefined_p ())
     vr0.set_varying (TREE_TYPE (op0));
   if (!query->range_of_expr (vr1, op1, s) || vr1.undefined_p ())
@@ -376,7 +376,7 @@  simplify_using_ranges::legacy_fold_cond_overflow (gimple *stmt)
 	}
       else
 	{
-	  value_range vro, vri;
+	  int_range_max vro, vri;
 	  tree type = TREE_TYPE (op0);
 	  if (code == GT_EXPR || code == GE_EXPR)
 	    {
@@ -399,7 +399,7 @@  simplify_using_ranges::legacy_fold_cond_overflow (gimple *stmt)
 	    }
 	  else
 	    gcc_unreachable ();
-	  value_range vr0;
+	  int_range_max vr0;
 	  if (!query->range_of_expr (vr0, op0, stmt))
 	    vr0.set_varying (TREE_TYPE (op0));
 	  /* If vro, the range for OP0 to pass the overflow test, has
@@ -479,7 +479,7 @@  simplify_using_ranges::legacy_fold_cond (gcond *stmt, edge *taken_edge_p)
    Returns true if the default label is not needed.  */
 
 static bool
-find_case_label_ranges (gswitch *stmt, const value_range *vr,
+find_case_label_ranges (gswitch *stmt, const irange *vr,
 			size_t *min_idx1, size_t *max_idx1,
 			size_t *min_idx2, size_t *max_idx2)
 {
@@ -611,9 +611,9 @@  simplify_using_ranges::simplify_truth_ops_using_ranges
       if (INTEGRAL_TYPE_P (TREE_TYPE (tem))
 	  && TYPE_PRECISION (TREE_TYPE (tem)) > 1)
 	{
-	  value_range vr (TREE_TYPE (tem),
-			  wi::zero (TYPE_PRECISION (TREE_TYPE (tem))),
-			  wi::one (TYPE_PRECISION (TREE_TYPE (tem))));
+	  int_range<1> vr (TREE_TYPE (tem),
+			   wi::zero (TYPE_PRECISION (TREE_TYPE (tem))),
+			   wi::one (TYPE_PRECISION (TREE_TYPE (tem))));
 	  set_range_info (tem, vr);
 	}
       gimple_assign_set_rhs_with_ops (gsi, NOP_EXPR, tem);
@@ -646,7 +646,7 @@  simplify_using_ranges::simplify_div_or_mod_using_ranges
   tree op1 = gimple_assign_rhs2 (stmt);
   tree op0min = NULL_TREE, op0max = NULL_TREE;
   tree op1min = op1;
-  value_range vr;
+  int_range_max vr;
 
   if (TREE_CODE (op0) == INTEGER_CST)
     {
@@ -668,7 +668,7 @@  simplify_using_ranges::simplify_div_or_mod_using_ranges
   if (rhs_code == TRUNC_MOD_EXPR
       && TREE_CODE (op1) == SSA_NAME)
     {
-      value_range vr1;
+      int_range_max vr1;
       if (!query->range_of_expr (vr1, op1, stmt))
 	vr1.set_varying (TREE_TYPE (op1));
       if (!vr1.varying_p () && !vr1.undefined_p ())
@@ -806,7 +806,7 @@  simplify_using_ranges::simplify_abs_using_ranges (gimple_stmt_iterator *gsi,
   return false;
 }
 
-/* value_range wrapper for wi_set_zero_nonzero_bits.
+/* irange wrapper for wi_set_zero_nonzero_bits.
 
    Return TRUE if VR was a constant range and we were able to compute
    the bit masks.  */
@@ -842,7 +842,7 @@  simplify_using_ranges::simplify_bit_ops_using_ranges
   tree op0 = gimple_assign_rhs1 (stmt);
   tree op1 = gimple_assign_rhs2 (stmt);
   tree op = NULL_TREE;
-  value_range vr0, vr1;
+  int_range_max vr0, vr1;
   wide_int may_be_nonzero0, may_be_nonzero1;
   wide_int must_be_nonzero0, must_be_nonzero1;
   wide_int mask;
@@ -914,7 +914,7 @@  simplify_using_ranges::simplify_bit_ops_using_ranges
 
 static tree
 test_for_singularity (enum tree_code cond_code, tree op0,
-		      tree op1, const value_range *vr)
+		      tree op1, const irange *vr)
 {
   tree min = NULL;
   tree max = NULL;
@@ -1226,7 +1226,7 @@  simplify_using_ranges::simplify_compare_using_ranges_1 (tree_code &cond_code, tr
       && INTEGRAL_TYPE_P (TREE_TYPE (op0))
       && is_gimple_min_invariant (op1))
     {
-      value_range vr;
+      int_range_max vr;
 
       if (!query->range_of_expr (vr, op0, stmt))
 	vr.set_undefined ();
@@ -1307,7 +1307,7 @@  simplify_using_ranges::simplify_casted_compare (tree_code &, tree &op0, tree &op
 	  && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (innerop)
 	  && desired_pro_or_demotion_p (TREE_TYPE (innerop), TREE_TYPE (op0)))
 	{
-	  value_range vr;
+	  int_range_max vr;
 
 	  if (query->range_of_expr (vr, innerop)
 	      && !vr.varying_p ()
@@ -1334,7 +1334,7 @@  bool
 simplify_using_ranges::simplify_switch_using_ranges (gswitch *stmt)
 {
   tree op = gimple_switch_index (stmt);
-  value_range vr;
+  int_range_max vr;
   bool take_default;
   edge e;
   edge_iterator ei;
@@ -1582,7 +1582,7 @@  simplify_conversion_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
   /* Get the value-range of the inner operand.  Use global ranges in
      case innerop was created during substitute-and-fold.  */
   wide_int imin, imax;
-  value_range vr;
+  int_range_max vr;
   if (!INTEGRAL_TYPE_P (TREE_TYPE (innerop)))
     return false;
   get_range_query (cfun)->range_of_expr (vr, innerop, stmt);
@@ -1643,7 +1643,7 @@  simplify_using_ranges::simplify_float_conversion_using_ranges
 					 gimple *stmt)
 {
   tree rhs1 = gimple_assign_rhs1 (stmt);
-  value_range vr;
+  int_range_max vr;
   scalar_float_mode fltmode
     = SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt)));
   scalar_int_mode mode;
@@ -1814,7 +1814,7 @@  bool
 simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b,
 					       gimple *s)
 {
-  value_range vr;
+  int_range_max vr;
   if (!query->range_of_expr (vr, var, s))
     return false;
   if (vr.varying_p () || vr.undefined_p ())