public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-369] Remove irange::{min,max,kind}.
@ 2023-05-01  6:33 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2023-05-01  6:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e1f83aa39dd5d4dbfd1045786e87bcac0b6561aa

commit r14-369-ge1f83aa39dd5d4dbfd1045786e87bcac0b6561aa
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Jan 24 19:28:59 2023 +0100

    Remove irange::{min,max,kind}.
    
    gcc/ChangeLog:
    
            * tree-ssa-loop-niter.cc (refine_value_range_using_guard): Remove
            kind() call.
            (determine_value_range): Same.
            (record_nonwrapping_iv): Same.
            (infer_loop_bounds_from_signedness): Same.
            (scev_var_range_cant_overflow): Same.
            * tree-vrp.cc (operand_less_p): Delete.
            * tree-vrp.h (operand_less_p): Delete.
            * value-range.cc (get_legacy_range): Remove uses of deprecated API.
            (irange::value_inside_range): Delete.
            * value-range.h (vrange::kind): Delete.
            (irange::num_pairs): Remove check of m_kind.
            (irange::min): Delete.
            (irange::max): Delete.

Diff:
---
 gcc/tree-ssa-loop-niter.cc | 26 ++++++++++++++++--------
 gcc/tree-vrp.cc            | 24 -----------------------
 gcc/tree-vrp.h             |  1 -
 gcc/value-range.cc         | 49 ----------------------------------------------
 gcc/value-range.h          | 37 +---------------------------------
 5 files changed, 19 insertions(+), 118 deletions(-)

diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index 33233979ba0..c0ed6573409 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -223,7 +223,8 @@ refine_value_range_using_guard (tree type, tree var,
   else if (TREE_CODE (varc1) == SSA_NAME
 	   && INTEGRAL_TYPE_P (type)
 	   && get_range_query (cfun)->range_of_expr (r, varc1)
-	   && r.kind () == VR_RANGE)
+	   && !r.undefined_p ()
+	   && !r.varying_p ())
     {
       gcc_assert (wi::le_p (r.lower_bound (), r.upper_bound (), sgn));
       wi::to_mpz (r.lower_bound (), minc1, sgn);
@@ -368,7 +369,10 @@ determine_value_range (class loop *loop, tree type, tree var, mpz_t off,
       /* Either for VAR itself...  */
       Value_Range var_range (TREE_TYPE (var));
       get_range_query (cfun)->range_of_expr (var_range, var);
-      rtype = var_range.kind ();
+      if (var_range.varying_p () || var_range.undefined_p ())
+	rtype = VR_VARYING;
+      else
+	rtype = VR_RANGE;
       if (!var_range.undefined_p ())
 	{
 	  minv = var_range.lower_bound ();
@@ -384,7 +388,8 @@ determine_value_range (class loop *loop, tree type, tree var, mpz_t off,
 	  if (PHI_ARG_DEF_FROM_EDGE (phi, e) == var
 	      && get_range_query (cfun)->range_of_expr (phi_range,
 						    gimple_phi_result (phi))
-	      && phi_range.kind () == VR_RANGE)
+	      && !phi_range.varying_p ()
+	      && !phi_range.undefined_p ())
 	    {
 	      if (rtype != VR_RANGE)
 		{
@@ -404,7 +409,10 @@ determine_value_range (class loop *loop, tree type, tree var, mpz_t off,
 		    {
 		      Value_Range vr (TREE_TYPE (var));
 		      get_range_query (cfun)->range_of_expr (vr, var);
-		      rtype = vr.kind ();
+		      if (vr.varying_p () || vr.undefined_p ())
+			rtype = VR_VARYING;
+		      else
+			rtype = VR_RANGE;
 		      if (!vr.undefined_p ())
 			{
 			  minv = vr.lower_bound ();
@@ -4045,7 +4053,8 @@ record_nonwrapping_iv (class loop *loop, tree base, tree step, gimple *stmt,
       if (TREE_CODE (orig_base) == SSA_NAME
 	  && TREE_CODE (high) == INTEGER_CST
 	  && INTEGRAL_TYPE_P (TREE_TYPE (orig_base))
-	  && (base_range.kind () == VR_RANGE
+	  && ((!base_range.varying_p ()
+	       && !base_range.undefined_p ())
 	      || get_cst_init_from_scev (orig_base, &max, false))
 	  && wi::gts_p (wi::to_wide (high), max))
 	base = wide_int_to_tree (unsigned_type, max);
@@ -4067,7 +4076,8 @@ record_nonwrapping_iv (class loop *loop, tree base, tree step, gimple *stmt,
       if (TREE_CODE (orig_base) == SSA_NAME
 	  && TREE_CODE (low) == INTEGER_CST
 	  && INTEGRAL_TYPE_P (TREE_TYPE (orig_base))
-	  && (base_range.kind () == VR_RANGE
+	  && ((!base_range.varying_p ()
+	       && !base_range.undefined_p ())
 	      || get_cst_init_from_scev (orig_base, &min, true))
 	  && wi::gts_p (min, wi::to_wide (low)))
 	base = wide_int_to_tree (unsigned_type, min);
@@ -4335,7 +4345,7 @@ infer_loop_bounds_from_signedness (class loop *loop, gimple *stmt)
   high = upper_bound_in_type (type, type);
   Value_Range r (TREE_TYPE (def));
   get_range_query (cfun)->range_of_expr (r, def);
-  if (r.kind () == VR_RANGE)
+  if (!r.varying_p () && !r.undefined_p ())
     {
       low = wide_int_to_tree (type, r.lower_bound ());
       high = wide_int_to_tree (type, r.upper_bound ());
@@ -5385,7 +5395,7 @@ scev_var_range_cant_overflow (tree var, tree step, class loop *loop)
 
   Value_Range r (TREE_TYPE (var));
   get_range_query (cfun)->range_of_expr (r, var);
-  if (r.kind () != VR_RANGE)
+  if (r.varying_p () || r.undefined_p ())
     return false;
 
   /* VAR is a scev whose evolution part is STEP and value range info
diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index 6c6e0382809..c0dcd50ee01 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -367,30 +367,6 @@ get_single_symbol (tree t, bool *neg, tree *inv)
   return t;
 }
 
-/* Return
-   1 if VAL < VAL2
-   0 if !(VAL < VAL2)
-   -2 if those are incomparable.  */
-int
-operand_less_p (tree val, tree val2)
-{
-  /* LT is folded faster than GE and others.  Inline the common case.  */
-  if (TREE_CODE (val) == INTEGER_CST && TREE_CODE (val2) == INTEGER_CST)
-    return tree_int_cst_lt (val, val2);
-  else if (TREE_CODE (val) == SSA_NAME && TREE_CODE (val2) == SSA_NAME)
-    return val == val2 ? 0 : -2;
-  else
-    {
-      int cmp = compare_values (val, val2);
-      if (cmp == -1)
-	return 1;
-      else if (cmp == 0 || cmp == 1)
-	return 0;
-      else
-	return -2;
-    }
-}
-
 /* Compare two values VAL1 and VAL2.  Return
 
    	-2 if VAL1 and VAL2 cannot be compared at compile-time,
diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h
index 58216388ee6..ba0a314d510 100644
--- a/gcc/tree-vrp.h
+++ b/gcc/tree-vrp.h
@@ -24,7 +24,6 @@ along with GCC; see the file COPYING3.  If not see
 
 extern int compare_values (tree, tree);
 extern int compare_values_warnv (tree, tree, bool *);
-extern int operand_less_p (tree, tree);
 
 extern enum value_range_kind intersect_range_with_nonzero_bits
   (enum value_range_kind, wide_int *, wide_int *, const wide_int &, signop);
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index c11c3f58d2c..ee43efa1ab5 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -907,15 +907,10 @@ irange::operator= (const irange &src)
 value_range_kind
 get_legacy_range (const irange &r, tree &min, tree &max)
 {
-  value_range_kind old_kind = r.kind ();
-  tree old_min = r.min ();
-  tree old_max = r.max ();
-
   if (r.undefined_p ())
     {
       min = NULL_TREE;
       max = NULL_TREE;
-      gcc_checking_assert (old_kind == VR_UNDEFINED);
       return VR_UNDEFINED;
     }
 
@@ -924,9 +919,6 @@ get_legacy_range (const irange &r, tree &min, tree &max)
     {
       min = wide_int_to_tree (type, r.lower_bound ());
       max = wide_int_to_tree (type, r.upper_bound ());
-      gcc_checking_assert (old_kind == VR_VARYING);
-      gcc_checking_assert (vrp_operand_equal_p (old_min, min));
-      gcc_checking_assert (vrp_operand_equal_p (old_max, max));
       return VR_VARYING;
     }
 
@@ -946,9 +938,6 @@ get_legacy_range (const irange &r, tree &min, tree &max)
 
   min = wide_int_to_tree (type, r.lower_bound ());
   max = wide_int_to_tree (type, r.upper_bound ());
-  gcc_checking_assert (old_kind == VR_RANGE);
-  gcc_checking_assert (vrp_operand_equal_p (old_min, min));
-  gcc_checking_assert (vrp_operand_equal_p (old_max, max));
   return VR_RANGE;
 }
 
@@ -1165,44 +1154,6 @@ irange::singleton_p (tree *result) const
   return false;
 }
 
-/* Return 1 if VAL is inside value range.
-	  0 if VAL is not inside value range.
-	 -2 if we cannot tell either way.
-
-   Benchmark compile/20001226-1.c compilation time after changing this
-   function.  */
-
-int
-irange::value_inside_range (tree val) const
-{
-  if (varying_p ())
-    return 1;
-
-  if (undefined_p ())
-    return 0;
-
-  gcc_checking_assert (TREE_CODE (val) == INTEGER_CST);
-
-  // FIXME:
-  if (TREE_CODE (val) == INTEGER_CST)
-    return contains_p (val);
-
-  int cmp1 = operand_less_p (val, min ());
-  if (cmp1 == -2)
-    return -2;
-  if (cmp1 == 1)
-    return m_kind != VR_RANGE;
-
-  int cmp2 = operand_less_p (max (), val);
-  if (cmp2 == -2)
-    return -2;
-
-  if (m_kind == VR_RANGE)
-    return !cmp2;
-  else
-    return !!cmp2;
-}
-
 /* Return TRUE if range contains INTEGER_CST.  */
 /* Return 1 if VAL is inside value range.
 	  0 if VAL is not inside value range.
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 9d485fbbe77..68f380a2dbb 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -166,10 +166,6 @@ public:
   wide_int get_nonzero_bits () const;
   void set_nonzero_bits (const wide_int_ref &bits);
 
-  // Deprecated legacy public methods.
-  tree min () const;				// DEPRECATED
-  tree max () const;				// DEPRECATED
-
 protected:
   irange (tree *, unsigned);
   // potential promotion to public?
@@ -188,7 +184,6 @@ protected:
   void normalize_kind ();
 
   void verify_range ();
-  int value_inside_range (tree) const;
 
 private:
   friend void gt_ggc_mx (irange *);
@@ -499,7 +494,6 @@ public:
   void set (tree min, tree max, value_range_kind kind = VR_RANGE)
     { return m_vrange->set (min, max, kind); }
   tree type () { return m_vrange->type (); }
-  enum value_range_kind kind () { return m_vrange->kind (); }
   bool varying_p () const { return m_vrange->varying_p (); }
   bool undefined_p () const { return m_vrange->undefined_p (); }
   void set_varying (tree type) { m_vrange->set_varying (type); }
@@ -645,26 +639,12 @@ extern bool vrp_operand_equal_p (const_tree, const_tree);
 inline REAL_VALUE_TYPE frange_val_min (const_tree type);
 inline REAL_VALUE_TYPE frange_val_max (const_tree type);
 
-inline value_range_kind
-vrange::kind () const
-{
-  return m_kind;
-}
-
 // Number of sub-ranges in a range.
 
 inline unsigned
 irange::num_pairs () const
 {
-  if (m_kind == VR_ANTI_RANGE)
-    {
-      bool constant_p = (TREE_CODE (min ()) == INTEGER_CST
-			 && TREE_CODE (max ()) == INTEGER_CST);
-      gcc_checking_assert (constant_p);
-      return 2;
-    }
-  else
-    return m_num_ranges;
+  return m_num_ranges;
 }
 
 inline tree
@@ -701,21 +681,6 @@ irange::tree_upper_bound () const
   return tree_upper_bound (m_num_ranges - 1);
 }
 
-inline tree
-irange::min () const
-{
-  return tree_lower_bound (0);
-}
-
-inline tree
-irange::max () const
-{
-  if (m_num_ranges)
-    return tree_upper_bound ();
-  else
-    return NULL;
-}
-
 inline bool
 irange::varying_compatible_p () const
 {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-01  6:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-01  6:33 [gcc r14-369] Remove irange::{min,max,kind} Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).