diff mbox series

[COMMITTED] Remove symbolics from irange.

Message ID 20230426083328.313566-7-aldyh@redhat.com
State New
Headers show
Series [COMMITTED] Remove symbolics from irange. | expand

Commit Message

Aldy Hernandez April 26, 2023, 8:33 a.m. UTC
gcc/ChangeLog:

	* value-range.cc (irange::copy_legacy_to_multi_range): Remove
	symbolics support.
	(irange::set): Same.
	(irange::legacy_lower_bound): Same.
	(irange::legacy_upper_bound): Same.
	(irange::contains_p): Same.
	(range_tests_legacy): Same.
	(irange::normalize_addresses): Remove.
	(irange::normalize_symbolics): Remove.
	(irange::symbolic_p): Remove.
	* value-range.h (class irange): Remove symbolic_p,
	normalize_symbolics, and normalize_addresses.
	* vr-values.cc (simplify_using_ranges::two_valued_val_range_p):
	Remove symbolics support.
---
 gcc/value-range.cc | 139 ++-------------------------------------------
 gcc/value-range.h  |   3 -
 gcc/vr-values.cc   |   1 -
 3 files changed, 4 insertions(+), 139 deletions(-)
diff mbox series

Patch

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 6c61bcefd6e..ebadea8b917 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -945,7 +945,6 @@  irange::copy_legacy_to_multi_range (const irange &src)
       else
 	{
 	  value_range cst (src);
-	  cst.normalize_symbolics ();
 	  gcc_checking_assert (cst.varying_p () || cst.kind () == VR_RANGE);
 	  set (cst.min (), cst.max ());
 	}
@@ -1153,17 +1152,10 @@  irange::set (tree min, tree max, value_range_kind kind)
 	}
       return;
     }
-  // Nothing to canonicalize for symbolic ranges.
-  if (TREE_CODE (min) != INTEGER_CST
-      || TREE_CODE (max) != INTEGER_CST)
-    {
-      m_kind = kind;
-      m_base[0] = min;
-      m_base[1] = max;
-      m_num_ranges = 1;
-      m_nonzero_mask = NULL;
-      return;
-    }
+
+  // Symbolics are not allowed in an irange.
+  gcc_checking_assert (TREE_CODE (min) == INTEGER_CST
+		       && TREE_CODE (max) == INTEGER_CST);
 
   swap_out_of_order_endpoints (min, max, kind);
   if (kind == VR_VARYING)
@@ -1264,12 +1256,6 @@  wide_int
 irange::legacy_lower_bound (unsigned pair) const
 {
   gcc_checking_assert (legacy_mode_p ());
-  if (symbolic_p ())
-    {
-      value_range numeric_range (*this);
-      numeric_range.normalize_symbolics ();
-      return numeric_range.legacy_lower_bound (pair);
-    }
   gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
   if (m_kind == VR_ANTI_RANGE)
@@ -1291,12 +1277,6 @@  wide_int
 irange::legacy_upper_bound (unsigned pair) const
 {
   gcc_checking_assert (legacy_mode_p ());
-  if (symbolic_p ())
-    {
-      value_range numeric_range (*this);
-      numeric_range.normalize_symbolics ();
-      return numeric_range.legacy_upper_bound (pair);
-    }
   gcc_checking_assert (m_num_ranges > 0);
   gcc_checking_assert (pair + 1 <= num_pairs ());
   if (m_kind == VR_ANTI_RANGE)
@@ -1371,16 +1351,6 @@  irange::operator== (const irange &other) const
   return nz1 == nz2;
 }
 
-/* Return TRUE if this is a symbolic range.  */
-
-bool
-irange::symbolic_p () const
-{
-  return (m_num_ranges > 0
-	  && (!is_gimple_min_invariant (min ())
-	      || !is_gimple_min_invariant (max ())));
-}
-
 /* Return TRUE if this is a constant range.  */
 
 bool
@@ -1492,12 +1462,6 @@  irange::contains_p (tree cst) const
   if (legacy_mode_p ())
     {
       gcc_checking_assert (TREE_CODE (cst) == INTEGER_CST);
-      if (symbolic_p ())
-	{
-	  value_range numeric_range (*this);
-	  numeric_range.normalize_symbolics ();
-	  return numeric_range.contains_p (cst);
-	}
       return value_inside_range (cst) == 1;
     }
 
@@ -1524,86 +1488,6 @@  irange::contains_p (tree cst) const
   return false;
 }
 
-
-/* Normalize addresses into constants.  */
-
-void
-irange::normalize_addresses ()
-{
-  if (undefined_p ())
-    return;
-
-  if (!POINTER_TYPE_P (type ()) || range_has_numeric_bounds_p (this))
-    return;
-
-  if (!range_includes_zero_p (this))
-    {
-      gcc_checking_assert (TREE_CODE (min ()) == ADDR_EXPR
-			   || TREE_CODE (max ()) == ADDR_EXPR);
-      set_nonzero (type ());
-      return;
-    }
-  set_varying (type ());
-}
-
-/* Normalize symbolics and addresses into constants.  */
-
-void
-irange::normalize_symbolics ()
-{
-  if (varying_p () || undefined_p ())
-    return;
-
-  tree ttype = type ();
-  bool min_symbolic = !is_gimple_min_invariant (min ());
-  bool max_symbolic = !is_gimple_min_invariant (max ());
-  if (!min_symbolic && !max_symbolic)
-    {
-      normalize_addresses ();
-      return;
-    }
-
-  // [SYM, SYM] -> VARYING
-  if (min_symbolic && max_symbolic)
-    {
-      set_varying (ttype);
-      return;
-    }
-  if (kind () == VR_RANGE)
-    {
-      // [SYM, NUM] -> [-MIN, NUM]
-      if (min_symbolic)
-	{
-	  set (vrp_val_min (ttype), max ());
-	  return;
-	}
-      // [NUM, SYM] -> [NUM, +MAX]
-      set (min (), vrp_val_max (ttype));
-      return;
-    }
-  gcc_checking_assert (kind () == VR_ANTI_RANGE);
-  // ~[SYM, NUM] -> [NUM + 1, +MAX]
-  if (min_symbolic)
-    {
-      if (!vrp_val_is_max (max ()))
-	{
-	  tree n = wide_int_to_tree (ttype, wi::to_wide (max ()) + 1);
-	  set (n, vrp_val_max (ttype));
-	  return;
-	}
-      set_varying (ttype);
-      return;
-    }
-  // ~[NUM, SYM] -> [-MIN, NUM - 1]
-  if (!vrp_val_is_min (min ()))
-    {
-      tree n = wide_int_to_tree (ttype, wi::to_wide (min ()) - 1);
-      set (vrp_val_min (ttype), n);
-      return;
-    }
-  set_varying (ttype);
-}
-
 /* Intersect the two value-ranges { *VR0TYPE, *VR0MIN, *VR0MAX } and
    { VR1TYPE, VR0MIN, VR0MAX } and store the result
    in { *VR0TYPE, *VR0MIN, *VR0MAX }.  This may not be the smallest
@@ -3525,21 +3409,6 @@  range_tests_legacy ()
   small = big;
   ASSERT_TRUE (small == int_range<1> (INT (21), INT (21), VR_ANTI_RANGE));
 
-  // Copying a legacy symbolic to an int_range should normalize the
-  // symbolic at copy time.
-  {
-    tree ssa = make_ssa_name (integer_type_node);
-    value_range legacy_range (ssa, INT (25));
-    int_range<2> copy = legacy_range;
-    ASSERT_TRUE (copy == int_range<2>  (vrp_val_min (integer_type_node),
-					INT (25)));
-
-    // Test that copying ~[abc_23, abc_23] to a multi-range yields varying.
-    legacy_range = value_range (ssa, ssa, VR_ANTI_RANGE);
-    copy = legacy_range;
-    ASSERT_TRUE (copy.varying_p ());
-  }
-
   // VARYING of different sizes should not be equal.
   tree big_type = build_nonstandard_integer_type (32, 1);
   tree small_type = build_nonstandard_integer_type (16, 1);
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 929dc551aa2..1012d007261 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -169,10 +169,7 @@  public:
   // Deprecated legacy public methods.
   tree min () const;				// DEPRECATED
   tree max () const;				// DEPRECATED
-  bool symbolic_p () const;			// DEPRECATED
   bool constant_p () const;			// DEPRECATED
-  void normalize_symbolics ();			// DEPRECATED
-  void normalize_addresses ();			// DEPRECATED
   bool legacy_verbose_union_ (const class irange *);	// DEPRECATED
   bool legacy_verbose_intersect (const irange *);	// DEPRECATED
 
diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc
index 841bcd1acb9..ba569b3f72f 100644
--- a/gcc/vr-values.cc
+++ b/gcc/vr-values.cc
@@ -2161,7 +2161,6 @@  simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b,
   value_range vr;
   if (!query->range_of_expr (vr, var, s))
     return false;
-  vr.normalize_symbolics ();
   if (vr.varying_p () || vr.undefined_p ())
     return false;