diff mbox series

[COMMITTED,15/16] Remove range_zero and range_nonzero.

Message ID 20240428190557.1209586-16-aldyh@redhat.com
State New
Headers show
Series prange supporting patchset | expand

Commit Message

Aldy Hernandez April 28, 2024, 7:05 p.m. UTC
Remove legacy range_zero and range_nonzero as they return by value,
which make it not work in a separate irange and prange world.  Also,
we already have set_zero and set_nonzero methods in vrange.

gcc/ChangeLog:

	* range-op-ptr.cc (pointer_plus_operator::wi_fold): Use method
	range setters instead of out of line functions.
	(pointer_min_max_operator::wi_fold): Same.
	(pointer_and_operator::wi_fold): Same.
	(pointer_or_operator::wi_fold): Same.
	* range-op.cc (operator_negate::fold_range): Same.
	(operator_addr_expr::fold_range): Same.
	(range_op_cast_tests): Same.
	* range.cc (range_zero): Remove.
	(range_nonzero): Remove.
	* range.h (range_zero): Remove.
	(range_nonzero): Remove.
	* value-range.cc (range_tests_misc): Use method instead of out of
	line function.
---
 gcc/range-op-ptr.cc | 14 +++++++-------
 gcc/range-op.cc     | 14 ++++++++------
 gcc/range.cc        | 14 --------------
 gcc/range.h         |  2 --
 gcc/value-range.cc  |  7 ++++---
 5 files changed, 19 insertions(+), 32 deletions(-)
diff mbox series

Patch

diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 2c85d75b5e8..7343ef635f3 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -101,10 +101,10 @@  pointer_plus_operator::wi_fold (irange &r, tree type,
       && !TYPE_OVERFLOW_WRAPS (type)
       && (flag_delete_null_pointer_checks
 	  || !wi::sign_mask (rh_ub)))
-    r = range_nonzero (type);
+    r.set_nonzero (type);
   else if (lh_lb == lh_ub && lh_lb == 0
 	   && rh_lb == rh_ub && rh_lb == 0)
-    r = range_zero (type);
+    r.set_zero (type);
   else
    r.set_varying (type);
 }
@@ -150,9 +150,9 @@  pointer_min_max_operator::wi_fold (irange &r, tree type,
   // are varying.
   if (!wi_includes_zero_p (type, lh_lb, lh_ub)
       && !wi_includes_zero_p (type, rh_lb, rh_ub))
-    r = range_nonzero (type);
+    r.set_nonzero (type);
   else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
-    r = range_zero (type);
+    r.set_zero (type);
   else
     r.set_varying (type);
 }
@@ -175,7 +175,7 @@  pointer_and_operator::wi_fold (irange &r, tree type,
   // For pointer types, we are really only interested in asserting
   // whether the expression evaluates to non-NULL.
   if (wi_zero_p (type, lh_lb, lh_ub) || wi_zero_p (type, lh_lb, lh_ub))
-    r = range_zero (type);
+    r.set_zero (type);
   else
     r.set_varying (type);
 }
@@ -236,9 +236,9 @@  pointer_or_operator::wi_fold (irange &r, tree type,
   // whether the expression evaluates to non-NULL.
   if (!wi_includes_zero_p (type, lh_lb, lh_ub)
       && !wi_includes_zero_p (type, rh_lb, rh_ub))
-    r = range_nonzero (type);
+    r.set_nonzero (type);
   else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
-    r = range_zero (type);
+    r.set_zero (type);
   else
     r.set_varying (type);
 }
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 6ea7d624a9b..ab3a4f0b200 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -4364,9 +4364,11 @@  operator_negate::fold_range (irange &r, tree type,
 {
   if (empty_range_varying (r, type, lh, rh))
     return true;
-  // -X is simply 0 - X.
-  return range_op_handler (MINUS_EXPR).fold_range (r, type,
-						   range_zero (type), lh);
+
+// -X is simply 0 - X.
+  int_range<1> zero;
+  zero.set_zero (type);
+  return range_op_handler (MINUS_EXPR).fold_range (r, type, zero, lh);
 }
 
 bool
@@ -4391,7 +4393,7 @@  operator_addr_expr::fold_range (irange &r, tree type,
 
   // Return a non-null pointer of the LHS type (passed in op2).
   if (lh.zero_p ())
-    r = range_zero (type);
+    r.set_zero (type);
   else if (lh.undefined_p () || contains_zero_p (lh))
     r.set_varying (type);
   else
@@ -4675,7 +4677,7 @@  range_op_cast_tests ()
   if (TYPE_PRECISION (integer_type_node)
       > TYPE_PRECISION (short_integer_type_node))
     {
-      r0 = range_nonzero (integer_type_node);
+      r0.set_nonzero (integer_type_node);
       range_cast (r0, short_integer_type_node);
       r1 = int_range<1> (short_integer_type_node,
 			 min_limit (short_integer_type_node),
@@ -4687,7 +4689,7 @@  range_op_cast_tests ()
   //
   // NONZERO signed 16-bits is [-MIN_16,-1][1, +MAX_16].
   // Converting this to 32-bits signed is [-MIN_16,-1][1, +MAX_16].
-  r0 = range_nonzero (short_integer_type_node);
+  r0.set_nonzero (short_integer_type_node);
   range_cast (r0, integer_type_node);
   r1 = int_range<1> (integer_type_node, INT (-32768), INT (-1));
   r2 = int_range<1> (integer_type_node, INT (1), INT (32767));
diff --git a/gcc/range.cc b/gcc/range.cc
index c68f387f71c..b362e0f12e0 100644
--- a/gcc/range.cc
+++ b/gcc/range.cc
@@ -29,20 +29,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "ssa.h"
 #include "range.h"
 
-value_range
-range_zero (tree type)
-{
-  wide_int zero = wi::zero (TYPE_PRECISION (type));
-  return value_range (type, zero, zero);
-}
-
-value_range
-range_nonzero (tree type)
-{
-  wide_int zero = wi::zero (TYPE_PRECISION (type));
-  return value_range (type, zero, zero, VR_ANTI_RANGE);
-}
-
 value_range
 range_positives (tree type)
 {
diff --git a/gcc/range.h b/gcc/range.h
index 391ea02daf5..eccb9490e4d 100644
--- a/gcc/range.h
+++ b/gcc/range.h
@@ -21,8 +21,6 @@  along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_RANGE_H
 #define GCC_RANGE_H
 
-value_range range_zero (tree type);
-value_range range_nonzero (tree type);
 value_range range_positives (tree type);
 value_range range_negatives (tree type);
 
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index d9689bd469f..a27de5534e1 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -2447,7 +2447,8 @@  range_tests_misc ()
   ASSERT_TRUE (not_255 == range_uchar (0, 254));
 
   // Test that NOT(0) is [1..255] in 8-bit land.
-  int_range<2> not_zero = range_nonzero (unsigned_char_type_node);
+  int_range<2> not_zero;
+  not_zero.set_nonzero (unsigned_char_type_node);
   ASSERT_TRUE (not_zero == range_uchar (1, 255));
 
   // Check that [0,127][0x..ffffff80,0x..ffffff]
@@ -2526,7 +2527,7 @@  range_tests_misc ()
   ASSERT_TRUE (r0 == r2);
 
   // Test that booleans and their inverse work as expected.
-  r0 = range_zero (boolean_type_node);
+  r0.set_zero (boolean_type_node);
   ASSERT_TRUE (r0 == range_false ());
   r0.invert ();
   ASSERT_TRUE (r0 == range_true ());
@@ -2534,7 +2535,7 @@  range_tests_misc ()
   // Make sure NULL and non-NULL of pointer types work, and that
   // inverses of them are consistent.
   tree voidp = build_pointer_type (void_type_node);
-  r0 = range_zero (voidp);
+  r0.set_zero (voidp);
   r1 = r0;
   r0.invert ();
   r0.invert ();