This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] place value_range_kind at the end of value_range constructors


This patch rewrites the value_range constructors so that value_range_kind is at the end, and defaults to VR_RANGE. This reduces the constructors by 2, and simplifies a lot of the common cases to read:

	value_range foo(x, y);
	blah.set(x,y);

instead of:

	value_range foo(VR_RANGE, x, y);
	blah.set(VR_RANGE x, y);

Pre-approved by Andrew.

Will commit as soon as tests finish.

Aldy
commit 272ccc1bc90c551a9c550565ad200edd235c2c0e
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed Nov 13 15:57:32 2019 +0100

    Rewrite value_range constructors to the value_range_kind is at the
    end, and defaults to VR_RANGE.  Similarly for set() methods.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 77ede4d0b2d..982418ec3c6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,48 @@
+2019-11-13  Aldy Hernandez  <aldyh@redhat.com>
+
+	* gimple-fold.c (size_must_be_zero_p): Rewrite use of value_range
+	constructors and set methods so value_range_kind is the last
+	argument and defaults to VR_RANGE.
+	* gimple-ssa-evrp-analyze.c (record_ranges_from_stmt): Same.
+	* ipa-cp.c (propagate_vr_across_jump_function): Same.
+	* ipa-prop.c (ipa_get_value_range): Same.
+	(ipa_compute_jump_functions_for_edge): Same.
+	* range-op.cc (value_range_from_overflowed_bounds): Same.
+	(operator_cast::op1_range): Same.
+	(range_tests): Same.
+	* range.cc (range_nonzero): Same.
+	* tree-ssanames.c (get_range_info): Same.
+	* tree-vrp.c (value_range_equiv::set): Same.
+	(value_range::value_range): Same.
+	(value_range_equiv::value_range_equiv): Same.
+	(value_range_equiv::update): Same.
+	(value_range_equiv::deep_copy): Same.
+	(value_range_equiv::move): Same.
+	(value_range_equiv::set_undefined): Same.
+	(value_range::set): Same.
+	(value_range::set_nonzero): Same.
+	(ranges_from_anti_range): Same.
+	(extract_range_from_plus_minus_expr): Same.
+	(value_range::intersect_helper): Same.
+	(value_range_equiv::intersect): Same.
+	(value_range::union_helper): Same.
+	(value_range_equiv::union_): Same.
+	(value_range::normalize_symbolics): Same.
+	(value_range::invert): Same.
+	(determine_value_range_1): Same.
+	* tree-vrp.h (class value_range): Same.
+	(class value_range_equiv): Same.
+	* vr-values.c (set_value_range_to_nonnegative): Same.
+	(set_value_range_to_truthvalue): Same.
+	(vr_values::update_value_range): Same.
+	(vr_values::extract_range_for_var_from_comparison_expr): Same.
+	(vr_values::extract_range_from_binary_expr): Same.
+	(vr_values::extract_range_from_comparison): Same.
+	(vr_values::extract_range_basic): Same.
+	(vr_values::adjust_range_with_scev): Same.
+	(vr_values::vrp_evaluate_conditional_warnv_with_ops): Same.
+	(vr_values::extract_range_from_phi_node): Same.
+
 2019-11-12  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
 	* tree-vect-loop.c (vect_transform_loop): Don't overwrite epilogues
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 1dfb2387533..e176be80efb 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -677,8 +677,7 @@ size_must_be_zero_p (tree size)
   /* Compute the value of SSIZE_MAX, the largest positive value that
      can be stored in ssize_t, the signed counterpart of size_t.  */
   wide_int ssize_max = wi::lshift (wi::one (prec), prec - 1) - 1;
-  value_range valid_range (VR_RANGE,
-			   build_int_cst (type, 0),
+  value_range valid_range (build_int_cst (type, 0),
 			   wide_int_to_tree (type, ssize_max));
   value_range vr;
   get_range_info (size, vr);
diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c
index 3a9fa75a678..5840767a799 100644
--- a/gcc/gimple-ssa-evrp-analyze.c
+++ b/gcc/gimple-ssa-evrp-analyze.c
@@ -334,7 +334,7 @@ evrp_range_analyzer::record_ranges_from_stmt (gimple *stmt, bool temporary)
 		 bitmaps.  Ugh.  */
 	      value_range_equiv *new_vr
 		= vr_values->allocate_value_range_equiv ();
-	      new_vr->set (vr.kind (), vr.min (), vr.max ());
+	      new_vr->set (vr.min (), vr.max (), NULL, vr.kind ());
 	      vr.equiv_clear ();
 	      push_value_range (output, new_vr);
 	    }
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index b1d899976e8..825d7f3e6ba 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -2003,7 +2003,7 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc,
 	  if (TREE_OVERFLOW_P (val))
 	    val = drop_tree_overflow (val);
 
-	  value_range tmpvr (VR_RANGE, val, val);
+	  value_range tmpvr (val, val);
 	  return dest_lat->meet_with (&tmpvr);
 	}
     }
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index a6c135f242b..514dea6acf1 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1821,9 +1821,9 @@ ipa_get_value_range (value_range *tmp)
    value_ranges.  */
 
 static value_range *
-ipa_get_value_range (enum value_range_kind type, tree min, tree max)
+ipa_get_value_range (enum value_range_kind kind, tree min, tree max)
 {
-  value_range tmp (type, min, max);
+  value_range tmp (min, max, kind);
   return ipa_get_value_range (&tmp);
 }
 
@@ -1913,16 +1913,16 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
       else
 	{
 	  wide_int min, max;
-	  value_range_kind type;
+	  value_range_kind kind;
 	  if (TREE_CODE (arg) == SSA_NAME
 	      && param_type
-	      && (type = get_range_info (arg, &min, &max))
-	      && (type == VR_RANGE || type == VR_ANTI_RANGE))
+	      && (kind = get_range_info (arg, &min, &max))
+	      && (kind == VR_RANGE || kind == VR_ANTI_RANGE))
 	    {
 	      value_range resvr;
-	      value_range tmpvr (type,
-				      wide_int_to_tree (TREE_TYPE (arg), min),
-				      wide_int_to_tree (TREE_TYPE (arg), max));
+	      value_range tmpvr (wide_int_to_tree (TREE_TYPE (arg), min),
+				 wide_int_to_tree (TREE_TYPE (arg), max),
+				 kind);
 	      range_fold_unary_expr (&resvr, NOP_EXPR, param_type,
 				     &tmpvr, TREE_TYPE (arg));
 	      if (!resvr.undefined_p () && !resvr.varying_p ())
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 9967f0c8653..5c7ff60b788 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -212,7 +212,7 @@ value_range_from_overflowed_bounds (value_range &r, tree type,
   if (covers || wi::cmp (tmin, tmax, sgn) > 0)
     r = value_range (type);
   else
-    r = value_range (VR_ANTI_RANGE, type, tmin, tmax);
+    r = value_range (type, tmin, tmax, VR_ANTI_RANGE);
 }
 
 // Create and return a range from a pair of wide-ints.  MIN_OVF and
@@ -1636,11 +1636,11 @@ operator_cast::op1_range (value_range &r, tree type,
 	  // *not* in the RHS is 0 or -1.
 	  unsigned prec = TYPE_PRECISION (type);
 	  if (lhs.zero_p ())
-	    r = value_range (VR_ANTI_RANGE, type,
-			     wi::minus_one (prec), wi::minus_one (prec));
+	    r = value_range (type, wi::minus_one (prec), wi::minus_one (prec),
+			     VR_ANTI_RANGE);
 	  else
-	    r = value_range (VR_ANTI_RANGE, type,
-			     wi::zero (prec), wi::zero (prec));
+	    r = value_range (type, wi::zero (prec), wi::zero (prec),
+			     VR_ANTI_RANGE);
 	  // And intersect it with what we know about op2.
 	  r.intersect (op2);
 	}
@@ -2835,7 +2835,7 @@ range_tests ()
   value_range r0, r1, rold;
 
   // Test that NOT(255) is [0..254] in 8-bit land.
-  value_range not_255 (VR_ANTI_RANGE, UCHAR (255), UCHAR (255));
+  value_range not_255 (UCHAR (255), UCHAR (255), VR_ANTI_RANGE);
   ASSERT_TRUE (not_255 == value_range (UCHAR (0), UCHAR (254)));
 
   // Test that NOT(0) is [1..255] in 8-bit land.
@@ -2876,17 +2876,17 @@ range_tests ()
   ASSERT_TRUE (r0 == value_range (UINT(6), maxuint));
 
   // Check that ~[10,MAX] => [0,9] for unsigned int.
-  r0 = value_range (VR_RANGE, UINT(10), maxuint);
+  r0 = value_range (UINT(10), maxuint);
   r0.invert ();
   ASSERT_TRUE (r0 == value_range (UINT (0), UINT (9)));
 
   // Check that ~[0,5] => [6,MAX] for unsigned 128-bit numbers.
-  r0 = value_range (VR_ANTI_RANGE, UINT128 (0), UINT128 (5));
+  r0 = value_range (UINT128 (0), UINT128 (5), VR_ANTI_RANGE);
   r1 = value_range (UINT128(6), build_minus_one_cst (u128_type));
   ASSERT_TRUE (r0 == r1);
 
   // Check that [~5] is really [-MIN,4][6,MAX].
-  r0 = value_range (VR_ANTI_RANGE, INT (5), INT (5));
+  r0 = value_range (INT (5), INT (5), VR_ANTI_RANGE);
   r1 = value_range (minint, INT (4));
   r1.union_ (value_range (INT (6), maxint));
   ASSERT_FALSE (r1.undefined_p ());
diff --git a/gcc/range.cc b/gcc/range.cc
index 8e5c979cf1e..e592d05738e 100644
--- a/gcc/range.cc
+++ b/gcc/range.cc
@@ -62,8 +62,8 @@ range_zero (tree type)
 value_range
 range_nonzero (tree type)
 {
-  return value_range (VR_ANTI_RANGE,
-			   build_zero_cst (type), build_zero_cst (type));
+  return value_range (build_zero_cst (type), build_zero_cst (type),
+		      VR_ANTI_RANGE);
 }
 
 value_range
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index ac92ae4e0e3..8d044901b19 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -455,7 +455,7 @@ get_range_info (const_tree name, value_range &vr)
     {
       min = wide_int_to_tree (TREE_TYPE (name), wmin);
       max = wide_int_to_tree (TREE_TYPE (name), wmax);
-      vr.set (kind, min, max);
+      vr.set (min, max, kind);
     }
   return kind;
 }
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index b8b6967dae7..08e8a7da3c9 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -103,31 +103,31 @@ value_range_equiv::set_equiv (bitmap equiv)
 /* Initialize value_range.  */
 
 void
-value_range_equiv::set (enum value_range_kind kind, tree min, tree max,
-			bitmap equiv)
+value_range_equiv::set (tree min, tree max, bitmap equiv,
+			value_range_kind kind)
 {
-  value_range::set (kind, min, max);
+  value_range::set (min, max, kind);
   set_equiv (equiv);
   if (flag_checking)
     check ();
 }
 
-value_range::value_range (value_range_kind kind, tree min, tree max)
+value_range::value_range (tree min, tree max, value_range_kind kind)
 {
-  set (kind, min, max);
+  set (min, max, kind);
 }
 
-value_range_equiv::value_range_equiv (value_range_kind kind,
-				      tree min, tree max, bitmap equiv)
+value_range_equiv::value_range_equiv (tree min, tree max, bitmap equiv,
+				      value_range_kind kind)
 {
   m_equiv = NULL;
-  set (kind, min, max, equiv);
+  set (min, max, equiv, kind);
 }
 
 value_range_equiv::value_range_equiv (const value_range &other)
 {
   m_equiv = NULL;
-  set (other.kind (), other.min(), other.max (), NULL);
+  set (other.min(), other.max (), NULL, other.kind ());
 }
 
 value_range::value_range (tree type)
@@ -135,35 +135,23 @@ value_range::value_range (tree type)
   set_varying (type);
 }
 
-value_range::value_range (enum value_range_kind kind, tree type,
-			  const wide_int &wmin, const wide_int &wmax)
-{
-  tree min = wide_int_to_tree (type, wmin);
-  tree max = wide_int_to_tree (type, wmax);
-  gcc_checking_assert (kind == VR_RANGE || kind == VR_ANTI_RANGE);
-  set (kind, min, max);
-}
-
 value_range::value_range (tree type,
-			  const wide_int &wmin, const wide_int &wmax)
+			  const wide_int &wmin, const wide_int &wmax,
+			  enum value_range_kind kind)
 {
   tree min = wide_int_to_tree (type, wmin);
   tree max = wide_int_to_tree (type, wmax);
-  set (VR_RANGE, min, max);
-}
-
-value_range::value_range (tree min, tree max)
-{
-  set (VR_RANGE, min, max);
+  gcc_checking_assert (kind == VR_RANGE || kind == VR_ANTI_RANGE);
+  set (min, max, kind);
 }
 
 /* Like set, but keep the equivalences in place.  */
 
 void
-value_range_equiv::update (value_range_kind kind, tree min, tree max)
+value_range_equiv::update (tree min, tree max, value_range_kind kind)
 {
-  set (kind, min, max,
-       (kind != VR_UNDEFINED && kind != VR_VARYING) ? m_equiv : NULL);
+  set (min, max,
+       (kind != VR_UNDEFINED && kind != VR_VARYING) ? m_equiv : NULL, kind);
 }
 
 /* Copy value_range in FROM into THIS while avoiding bitmap sharing.
@@ -175,13 +163,13 @@ value_range_equiv::update (value_range_kind kind, tree min, tree max)
 void
 value_range_equiv::deep_copy (const value_range_equiv *from)
 {
-  set (from->m_kind, from->min (), from->max (), from->m_equiv);
+  set (from->min (), from->max (), from->m_equiv, from->m_kind);
 }
 
 void
 value_range_equiv::move (value_range_equiv *from)
 {
-  set (from->m_kind, from->min (), from->max ());
+  set (from->min (), from->max (), NULL, from->m_kind);
   m_equiv = from->m_equiv;
   from->m_equiv = NULL;
 }
@@ -310,7 +298,7 @@ value_range::set_undefined ()
 void
 value_range_equiv::set_undefined ()
 {
-  set (VR_UNDEFINED, NULL, NULL, NULL);
+  set (NULL, NULL, NULL, VR_UNDEFINED);
 }
 
 void
@@ -715,7 +703,7 @@ intersect_range_with_nonzero_bits (enum value_range_kind vr_type,
    extract ranges from var + CST op limit.  */
 
 void
-value_range::set (enum value_range_kind kind, tree min, tree max)
+value_range::set (tree min, tree max, value_range_kind kind)
 {
   /* Use the canonical setters for VR_UNDEFINED and VR_VARYING.  */
   if (kind == VR_UNDEFINED)
@@ -879,7 +867,7 @@ value_range::set (tree val)
   gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant (val));
   if (TREE_OVERFLOW_P (val))
     val = drop_tree_overflow (val);
-  set (VR_RANGE, val, val);
+  set (val, val);
 }
 
 void
@@ -888,7 +876,7 @@ value_range_equiv::set (tree val)
   gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant (val));
   if (TREE_OVERFLOW_P (val))
     val = drop_tree_overflow (val);
-  set (VR_RANGE, val, val, NULL);
+  set (val, val);
 }
 
 /* Set value range VR to a nonzero range of type TYPE.  */
@@ -897,7 +885,7 @@ void
 value_range::set_nonzero (tree type)
 {
   tree zero = build_int_cst (type, 0);
-  set (VR_ANTI_RANGE, zero, zero);
+  set (zero, zero, VR_ANTI_RANGE);
 }
 
 /* Set value range VR to a ZERO range of type TYPE.  */
@@ -1283,12 +1271,10 @@ ranges_from_anti_range (const value_range *ar,
     return false;
 
   if (tree_int_cst_lt (vrp_val_min (type), ar->min ()))
-    vr0->set (VR_RANGE,
-	      vrp_val_min (type),
+    vr0->set (vrp_val_min (type),
 	      wide_int_to_tree (type, wi::to_wide (ar->min ()) - 1));
   if (tree_int_cst_lt (ar->max (), vrp_val_max (type)))
-    vr1->set (VR_RANGE,
-	      wide_int_to_tree (type, wi::to_wide (ar->max ()) + 1),
+    vr1->set (wide_int_to_tree (type, wi::to_wide (ar->max ()) + 1),
 	      vrp_val_max (type));
   if (vr0->undefined_p ())
     {
@@ -1701,7 +1687,7 @@ extract_range_from_plus_minus_expr (value_range *vr,
       vr->set_varying (expr_type);
     }
   else
-    vr->set (kind, min, max);
+    vr->set (min, max, kind);
 }
 
 /* Return the range-ops handler for CODE and EXPR_TYPE.  If no
@@ -5855,21 +5841,21 @@ value_range::intersect_helper (const value_range *vr0, const value_range *vr1)
   if (vr1->undefined_p ())
     return *vr1;
 
-  value_range_kind vr0type = vr0->kind ();
+  value_range_kind vr0kind = vr0->kind ();
   tree vr0min = vr0->min ();
   tree vr0max = vr0->max ();
-  intersect_ranges (&vr0type, &vr0min, &vr0max,
+  intersect_ranges (&vr0kind, &vr0min, &vr0max,
 		    vr1->kind (), vr1->min (), vr1->max ());
   /* Make sure to canonicalize the result though as the inversion of a
      VR_RANGE can still be a VR_RANGE.  Work on a temporary so we can
      fall back to vr0 when this turns things to varying.  */
   value_range tem;
-  if (vr0type == VR_UNDEFINED)
+  if (vr0kind == VR_UNDEFINED)
     tem.set_undefined ();
-  else if (vr0type == VR_VARYING)
+  else if (vr0kind == VR_VARYING)
     tem.set_varying (vr0->type ());
   else
-    tem.set (vr0type, vr0min, vr0max);
+    tem.set (vr0min, vr0max, vr0kind);
   /* If that failed, use the saved original VR0.  */
   if (tem.varying_p ())
     return *vr0;
@@ -5919,7 +5905,7 @@ value_range_equiv::intersect (const value_range_equiv *other)
   else
     {
       value_range tem = intersect_helper (this, other);
-      this->update (tem.kind (), tem.min (), tem.max ());
+      this->update (tem.min (), tem.max (), tem.kind ());
 
       /* If the result is VR_UNDEFINED there is no need to mess with
 	 equivalencies.  */
@@ -5965,20 +5951,20 @@ value_range::union_helper (const value_range *vr0, const value_range *vr1)
       || vr1->varying_p ())
     return *vr1;
 
-  value_range_kind vr0type = vr0->kind ();
+  value_range_kind vr0kind = vr0->kind ();
   tree vr0min = vr0->min ();
   tree vr0max = vr0->max ();
-  union_ranges (&vr0type, &vr0min, &vr0max,
+  union_ranges (&vr0kind, &vr0min, &vr0max,
 		vr1->kind (), vr1->min (), vr1->max ());
 
   /* Work on a temporary so we can still use vr0 when union returns varying.  */
   value_range tem;
-  if (vr0type == VR_UNDEFINED)
+  if (vr0kind == VR_UNDEFINED)
     tem.set_undefined ();
-  else if (vr0type == VR_VARYING)
+  else if (vr0kind == VR_VARYING)
     tem.set_varying (vr0->type ());
   else
-    tem.set (vr0type, vr0min, vr0max);
+    tem.set (vr0min, vr0max, vr0kind);
 
   /* Failed to find an efficient meet.  Before giving up and setting
      the result to VARYING, see if we can at least derive a useful
@@ -6040,7 +6026,7 @@ value_range_equiv::union_ (const value_range_equiv *other)
   else
     {
       value_range tem = union_helper (this, other);
-      this->update (tem.kind (), tem.min (), tem.max ());
+      this->update (tem.min (), tem.max (), tem.kind ());
 
       /* The resulting set of equivalences is always the intersection of
 	 the two sets.  */
@@ -6102,9 +6088,9 @@ value_range::normalize_symbolics () const
     {
       // [SYM, NUM] -> [-MIN, NUM]
       if (min_symbolic)
-	return value_range (VR_RANGE, vrp_val_min (ttype), max ());
+	return value_range (vrp_val_min (ttype), max ());
       // [NUM, SYM] -> [NUM, +MAX]
-      return value_range (VR_RANGE, min (), vrp_val_max (ttype));
+      return value_range (min (), vrp_val_max (ttype));
     }
   gcc_checking_assert (kind () == VR_ANTI_RANGE);
   // ~[SYM, NUM] -> [NUM + 1, +MAX]
@@ -6113,7 +6099,7 @@ value_range::normalize_symbolics () const
       if (!vrp_val_is_max (max ()))
 	{
 	  tree n = wide_int_to_tree (ttype, wi::to_wide (max ()) + 1);
-	  return value_range (VR_RANGE, n, vrp_val_max (ttype));
+	  return value_range (n, vrp_val_max (ttype));
 	}
       value_range var;
       var.set_varying (ttype);
@@ -6123,7 +6109,7 @@ value_range::normalize_symbolics () const
   if (!vrp_val_is_min (min ()))
     {
       tree n = wide_int_to_tree (ttype, wi::to_wide (min ()) - 1);
-      return value_range (VR_RANGE, vrp_val_min (ttype), n);
+      return value_range (vrp_val_min (ttype), n);
     }
   value_range var;
   var.set_varying (ttype);
@@ -6231,9 +6217,9 @@ value_range::invert ()
   /* We can't just invert VR_RANGE and VR_ANTI_RANGE because we may
      create non-canonical ranges.  Use the constructors instead.  */
   if (m_kind == VR_RANGE)
-    *this = value_range (VR_ANTI_RANGE, m_min, m_max);
+    *this = value_range (m_min, m_max, VR_ANTI_RANGE);
   else if (m_kind == VR_ANTI_RANGE)
-    *this = value_range (VR_RANGE, m_min, m_max);
+    *this = value_range (m_min, m_max);
   else
     gcc_unreachable ();
 }
@@ -6945,8 +6931,9 @@ determine_value_range_1 (value_range *vr, tree expr)
       if (TREE_CODE (expr) == SSA_NAME
 	  && INTEGRAL_TYPE_P (TREE_TYPE (expr))
 	  && (kind = get_range_info (expr, &min, &max)) != VR_VARYING)
-	vr->set (kind, wide_int_to_tree (TREE_TYPE (expr), min),
-		 wide_int_to_tree (TREE_TYPE (expr), max));
+	vr->set (wide_int_to_tree (TREE_TYPE (expr), min),
+		 wide_int_to_tree (TREE_TYPE (expr), max),
+		 kind);
       else
 	vr->set_varying (TREE_TYPE (expr));
     }
diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h
index 766fb635ab8..4b0e9c7a226 100644
--- a/gcc/tree-vrp.h
+++ b/gcc/tree-vrp.h
@@ -42,14 +42,12 @@ class GTY((for_user)) value_range
   friend void range_tests ();
 public:
   value_range ();
-  value_range (value_range_kind, tree, tree);
-  value_range (tree, tree);
-  value_range (value_range_kind,
-	       tree type, const wide_int &, const wide_int &);
-  value_range (tree type, const wide_int &, const wide_int &);
+  value_range (tree, tree, value_range_kind = VR_RANGE);
+  value_range (tree type, const wide_int &, const wide_int &,
+	       value_range_kind = VR_RANGE);
   value_range (tree type);
 
-  void set (value_range_kind, tree, tree);
+  void set (tree, tree, value_range_kind = VR_RANGE);
   void set (tree);
   void set_nonzero (tree);
   void set_zero (tree);
@@ -128,7 +126,7 @@ class GTY((user)) value_range_equiv : public value_range
   value_range_equiv ();
   value_range_equiv (const value_range &);
   /* Deep-copies equiv bitmap argument.  */
-  value_range_equiv (value_range_kind, tree, tree, bitmap = NULL);
+  value_range_equiv (tree, tree, bitmap = NULL, value_range_kind = VR_RANGE);
 
   /* Shallow-copies equiv bitmap.  */
   value_range_equiv (const value_range_equiv &) /* = delete */;
@@ -139,9 +137,9 @@ class GTY((user)) value_range_equiv : public value_range
   void move (value_range_equiv *);
 
   /* Leaves equiv bitmap alone.  */
-  void update (value_range_kind, tree, tree);
+  void update (tree, tree, value_range_kind = VR_RANGE);
   /* Deep-copies equiv bitmap argument.  */
-  void set (value_range_kind, tree, tree, bitmap = NULL);
+  void set (tree, tree, bitmap = NULL, value_range_kind = VR_RANGE);
   void set (tree);
 
   bool operator== (const value_range_equiv &) const /* = delete */;
diff --git a/gcc/vr-values.c b/gcc/vr-values.c
index b970339d0e0..9143fa0c30b 100644
--- a/gcc/vr-values.c
+++ b/gcc/vr-values.c
@@ -57,7 +57,7 @@ static inline void
 set_value_range_to_nonnegative (value_range_equiv *vr, tree type)
 {
   tree zero = build_int_cst (type, 0);
-  vr->update (VR_RANGE, zero, vrp_val_max (type));
+  vr->update (zero, vrp_val_max (type));
 }
 
 /* Set value range VR to a range of a truthvalue of type TYPE.  */
@@ -68,7 +68,7 @@ set_value_range_to_truthvalue (value_range_equiv *vr, tree type)
   if (TYPE_PRECISION (type) == 1)
     vr->set_varying (type);
   else
-    vr->update (VR_RANGE, build_int_cst (type, 0), build_int_cst (type, 1));
+    vr->update (build_int_cst (type, 0), build_int_cst (type, 1));
 }
 
 /* Return the lattice entry for VAR or NULL if it doesn't exist or cannot
@@ -246,8 +246,8 @@ vr_values::update_value_range (const_tree var, value_range_equiv *new_vr)
 	  return true;
 	}
       else
-	old_vr->set (new_vr->kind (),
-		     new_vr->min (), new_vr->max (), new_vr->equiv ());
+	old_vr->set (new_vr->min (), new_vr->max (), new_vr->equiv (),
+		     new_vr->kind ());
     }
 
   new_vr->equiv_clear ();
@@ -539,30 +539,30 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var,
          vice-versa.  Use set_and_canonicalize which does this for
          us.  */
       if (cond_code == LE_EXPR)
-	vr_p->set (VR_RANGE, min, max, vr_p->equiv ());
+	vr_p->set (min, max, vr_p->equiv ());
       else if (cond_code == GT_EXPR)
-        vr_p->set (VR_ANTI_RANGE, min, max, vr_p->equiv ());
+	vr_p->set (min, max, vr_p->equiv (), VR_ANTI_RANGE);
       else
 	gcc_unreachable ();
     }
   else if (cond_code == EQ_EXPR)
     {
-      enum value_range_kind range_type;
+      enum value_range_kind range_kind;
 
       if (limit_vr)
 	{
-	  range_type = limit_vr->kind ();
+	  range_kind = limit_vr->kind ();
 	  min = limit_vr->min ();
 	  max = limit_vr->max ();
 	}
       else
 	{
-	  range_type = VR_RANGE;
+	  range_kind = VR_RANGE;
 	  min = limit;
 	  max = limit;
 	}
 
-      vr_p->update (range_type, min, max);
+      vr_p->update (min, max, range_kind);
 
       /* When asserting the equality VAR == LIMIT and LIMIT is another
 	 SSA name, the new range will also inherit the equivalence set
@@ -613,7 +613,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var,
 	  && vrp_val_is_max (max))
 	min = max = limit;
 
-      vr_p->set (VR_ANTI_RANGE, min, max, vr_p->equiv ());
+      vr_p->set (min, max, vr_p->equiv (), VR_ANTI_RANGE);
     }
   else if (cond_code == LE_EXPR || cond_code == LT_EXPR)
     {
@@ -652,7 +652,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var,
 		TREE_NO_WARNING (max) = 1;
 	    }
 
-	  vr_p->update (VR_RANGE, min, max);
+	  vr_p->update (min, max);
 	}
     }
   else if (cond_code == GE_EXPR || cond_code == GT_EXPR)
@@ -692,7 +692,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var,
 		TREE_NO_WARNING (min) = 1;
 	    }
 
-	  vr_p->update (VR_RANGE, min, max);
+	  vr_p->update (min, max);
 	}
     }
   else
@@ -832,7 +832,7 @@ vr_values::extract_range_from_binary_expr (value_range_equiv *vr,
 	      wide_int wmax = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max)));
 	      tree range_min = build_zero_cst (expr_type);
 	      tree range_max = wide_int_to_tree (expr_type, wmax - 1);
-	      vr->set (VR_RANGE, range_min, range_max);
+	      vr->set (range_min, range_max);
 	      return;
 	    }
      }
@@ -853,15 +853,15 @@ vr_values::extract_range_from_binary_expr (value_range_equiv *vr,
 
       /* Try with VR0 and [-INF, OP1].  */
       if (is_gimple_min_invariant (minus_p ? vr0.max () : vr0.min ()))
-	n_vr1.set (VR_RANGE, vrp_val_min (expr_type), op1);
+	n_vr1.set (vrp_val_min (expr_type), op1);
 
       /* Try with VR0 and [OP1, +INF].  */
       else if (is_gimple_min_invariant (minus_p ? vr0.min () : vr0.max ()))
-	n_vr1.set (VR_RANGE, op1, vrp_val_max (expr_type));
+	n_vr1.set (op1, vrp_val_max (expr_type));
 
       /* Try with VR0 and [OP1, OP1].  */
       else
-	n_vr1.set (VR_RANGE, op1, op1);
+	n_vr1.set (op1, op1);
 
       range_fold_binary_expr (vr, code, expr_type, &vr0, &n_vr1);
     }
@@ -877,11 +877,11 @@ vr_values::extract_range_from_binary_expr (value_range_equiv *vr,
 
       /* Try with [-INF, OP0] and VR1.  */
       if (is_gimple_min_invariant (minus_p ? vr1.max () : vr1.min ()))
-	n_vr0.set (VR_RANGE, vrp_val_min (expr_type), op0);
+	n_vr0.set (vrp_val_min (expr_type), op0);
 
       /* Try with [OP0, +INF] and VR1.  */
       else if (is_gimple_min_invariant (minus_p ? vr1.min (): vr1.max ()))
-	n_vr0.set (VR_RANGE, op0, vrp_val_max (expr_type));
+	n_vr0.set (op0, vrp_val_max (expr_type));
 
       /* Try with [OP0, OP0] and VR1.  */
       else
@@ -989,7 +989,7 @@ vr_values::extract_range_from_comparison (value_range_equiv *vr,
       if (is_gimple_min_invariant (val))
 	vr->set (val);
       else
-	vr->update (VR_RANGE, val, val);
+	vr->update (val, val);
     }
   else
     /* The result of a comparison is always true or false.  */
@@ -1270,8 +1270,7 @@ vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt)
 	  maxi = prec - 1;
 	  goto bitop_builtin;
 	bitop_builtin:
-	  vr->set (VR_RANGE, build_int_cst (type, mini),
-		   build_int_cst (type, maxi));
+	  vr->set (build_int_cst (type, mini), build_int_cst (type, maxi));
 	  return;
 	case CFN_UBSAN_CHECK_ADD:
 	  subcode = PLUS_EXPR;
@@ -1298,7 +1297,7 @@ vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt)
 	      size = targetm.goacc.dim_limit (axis);
 
 	    tree type = TREE_TYPE (gimple_call_lhs (stmt));
-	    vr->set(VR_RANGE, build_int_cst (type, is_pos ? 0 : 1),
+	    vr->set(build_int_cst (type, is_pos ? 0 : 1),
 		    size
 		    ? build_int_cst (type, size - is_pos) : vrp_val_max (type));
 	  }
@@ -1319,7 +1318,7 @@ vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt)
 		   smaller than the former type).
 		   FIXME: Use max_object_size() - 1 here.  */
 		tree range_max = wide_int_to_tree (type, wmax - 2);
-		vr->set (VR_RANGE, range_min, range_max);
+		vr->set (range_min, range_max);
 		return;
 	      }
 	  break;
@@ -1381,7 +1380,7 @@ vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt)
 		    {
 		      /* This is the boolean return value whether compare and
 			 exchange changed anything or not.  */
-		      vr->set (VR_RANGE, build_int_cst (type, 0),
+		      vr->set (build_int_cst (type, 0),
 			       build_int_cst (type, 1));
 		      return;
 		    }
@@ -1403,7 +1402,7 @@ vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt)
 			       && !TYPE_UNSIGNED (type))
 			vr->set_varying (type);
 		      else
-			vr->set (VR_RANGE, build_int_cst (type, 0),
+			vr->set (build_int_cst (type, 0),
 				 build_int_cst (type, 1));
 		    }
 		  else if (types_compatible_p (type, TREE_TYPE (op0))
@@ -1921,7 +1920,7 @@ vr_values::adjust_range_with_scev (value_range_equiv *vr, class loop *loop,
   if (TREE_OVERFLOW_P (max))
     max = drop_tree_overflow (max);
 
-  vr->update (VR_RANGE, min, max);
+  vr->update (min, max);
 }
 
 /* Dump value ranges of all SSA_NAMEs to FILE.  */
@@ -2383,13 +2382,13 @@ vr_values::vrp_evaluate_conditional_warnv_with_ops (enum tree_code code,
 	  value_range vro, vri;
 	  if (code == GT_EXPR || code == GE_EXPR)
 	    {
-	      vro.set (VR_ANTI_RANGE, TYPE_MIN_VALUE (TREE_TYPE (op0)), x);
-	      vri.set (VR_RANGE, TYPE_MIN_VALUE (TREE_TYPE (op0)), x);
+	      vro.set (TYPE_MIN_VALUE (TREE_TYPE (op0)), x, VR_ANTI_RANGE);
+	      vri.set (TYPE_MIN_VALUE (TREE_TYPE (op0)), x);
 	    }
 	  else if (code == LT_EXPR || code == LE_EXPR)
 	    {
-	      vro.set (VR_RANGE, TYPE_MIN_VALUE (TREE_TYPE (op0)), x);
-	      vri.set (VR_ANTI_RANGE, TYPE_MIN_VALUE (TREE_TYPE (op0)), x);
+	      vro.set (TYPE_MIN_VALUE (TREE_TYPE (op0)), x);
+	      vri.set (TYPE_MIN_VALUE (TREE_TYPE (op0)), x, VR_ANTI_RANGE);
 	    }
 	  else
 	    gcc_unreachable ();
@@ -2873,8 +2872,8 @@ vr_values::extract_range_from_phi_node (gphi *phi,
 		{
 		  if (!vr_arg_->varying_p () && !vr_arg_->undefined_p ())
 		    {
-		      vr_arg_tem.set (vr_arg_->kind (), vr_arg_->min (),
-				      vr_arg_->max (), NULL);
+		      vr_arg_tem.set (vr_arg_->min (), vr_arg_->max (), NULL,
+				      vr_arg_->kind ());
 		      if (vr_arg_tem.symbolic_p ())
 			vr_arg_tem.set_varying (TREE_TYPE (arg));
 		    }
@@ -2984,7 +2983,7 @@ vr_values::extract_range_from_phi_node (gphi *phi,
 				   vrp_val_max (vr_result->type ()),
 				   build_int_cst (vr_result->type (), 1));
 
-      vr_result->update (vr_result->kind (), new_min, new_max);
+      vr_result->update (new_min, new_max, vr_result->kind ());
 
       /* If we dropped either bound to +-INF then if this is a loop
 	 PHI node SCEV may known more about its value-range.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]