[committed] remove multi-range selftests from range-ops.cc
diff mbox series

Message ID 991438b1-67cd-fb58-aaa4-8a6261af337d@redhat.com
State New
Headers show
Series
  • [committed] remove multi-range selftests from range-ops.cc
Related show

Commit Message

Aldy Hernandez Nov. 14, 2019, 7:54 a.m. UTC
Multi-range selftests are unused, as we don't currently have them on 
trunk.  This was leftover from the original ranger branch.  Removing 
them has the added benefit that the selftests no longer need to peek at 
m_max_pairs, so value_range no longer needs to friend the selftests.

This tidies up the selftest.h header file, and allows us to put the 
range tests in the correct namespace.

Committed as obvious.

Patch
diff mbox series

commit d542175952566dc3c43078d65a5a6e0f638a30e2
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu Nov 14 08:14:59 2019 +0100

    Remove higher precision range tests because they are unused.
    This removes the dependency on m_max_pairs from the selftests, which has
    the ultimate effect of allowing us to put the tests in the selftest
    namespace as was the original plan.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index db5c5e6aeba..cfb88e67c8c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@ 
+2019-11-14  Aldy Hernandez  <aldyh@redhat.com>
+
+	* range-op.cc (RANGE3): Remove.
+	(range_tests): Remove all selftest that check for multi-ranges.
+	Put tests in namespace selftest.
+	* selftest.h: Move range_tests into namespace selftest.
+	* value-range.h (class value_range): Unfriend range_tests.
+
 2019-11-14  Aldy Hernandez  <aldyh@redhat.com>
 
 	* tree-vrp.c (range_fold_binary_symbolics_p): Adapt for
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 5c7ff60b788..ae3025c6eea 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -2803,10 +2803,8 @@  range_cast (value_range &r, tree type)
 #include "selftest.h"
 #include "stor-layout.h"
 
-// Ideally this should go in namespace selftest, but range_tests
-// needs to be a friend of class value_range so it can access
-// value_range::m_max_pairs.
-
+namespace selftest
+{
 #define INT(N) build_int_cst (integer_type_node, (N))
 #define UINT(N) build_int_cstu (unsigned_type_node, (N))
 #define INT16(N) build_int_cst (short_integer_type_node, (N))
@@ -2817,14 +2815,6 @@  range_cast (value_range &r, tree type)
 #define UCHAR(N) build_int_cstu (unsigned_char_type_node, (N))
 #define SCHAR(N) build_int_cst (signed_char_type_node, (N))
 
-#define RANGE3(A,B,C,D,E,F)		\
-( i1 = value_range (INT (A), INT (B)),	\
-  i2 = value_range (INT (C), INT (D)),	\
-  i3 = value_range (INT (E), INT (F)),	\
-  i1.union_ (i2),			\
-  i1.union_ (i3),			\
-  i1 )
-
 // Run all of the selftests within this file.
 
 void
@@ -2893,16 +2883,13 @@  range_tests ()
   ASSERT_TRUE (r0 == r1);
 
   r1 = value_range (INT (5), INT (5));
-  r1.check ();
   value_range r2 (r1);
   ASSERT_TRUE (r1 == r2);
 
   r1 = value_range (INT (5), INT (10));
-  r1.check ();
 
   r1 = value_range (integer_type_node,
 	       wi::to_wide (INT (5)), wi::to_wide (INT (10)));
-  r1.check ();
   ASSERT_TRUE (r1.contains_p (INT (7)));
 
   r1 = value_range (SCHAR (0), SCHAR (20));
@@ -3046,42 +3033,12 @@  range_tests ()
   r1.union_ (r2);
   ASSERT_TRUE (r0 == r1);
 
-  if (value_range::m_max_pairs > 2)
-    {
-      // ([10,20] U [5,8]) U [1,3] ==> [1,3][5,8][10,20].
-      r0 = value_range (INT (10), INT (20));
-      r1 = value_range (INT (5), INT (8));
-      r0.union_ (r1);
-      r1 = value_range (INT (1), INT (3));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == RANGE3 (1, 3, 5, 8, 10, 20));
-
-      // [1,3][5,8][10,20] U [-5,0] => [-5,3][5,8][10,20].
-      r1 = value_range (INT (-5), INT (0));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == RANGE3 (-5, 3, 5, 8, 10, 20));
-    }
-
   // [10,20] U [30,40] ==> [10,20][30,40].
   r0 = value_range (INT (10), INT (20));
   r1 = value_range (INT (30), INT (40));
   r0.union_ (r1);
   ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
 				  value_range (INT (30), INT (40))));
-  if (value_range::m_max_pairs > 2)
-    {
-      // [10,20][30,40] U [50,60] ==> [10,20][30,40][50,60].
-      r1 = value_range (INT (50), INT (60));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == RANGE3 (10, 20, 30, 40, 50, 60));
-      // [10,20][30,40][50,60] U [70, 80] ==> [10,20][30,40][50,60][70,80].
-      r1 = value_range (INT (70), INT (80));
-      r0.union_ (r1);
-
-      r2 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r2.union_ (value_range (INT (70), INT (80)));
-      ASSERT_TRUE (r0 == r2);
-    }
 
   // Make sure NULL and non-NULL of pointer types work, and that
   // inverses of them are consistent.
@@ -3092,35 +3049,6 @@  range_tests ()
   r0.invert ();
   ASSERT_TRUE (r0 == r1);
 
-  if (value_range::m_max_pairs > 2)
-    {
-      // [10,20][30,40][50,60] U [6,35] => [6,40][50,60].
-      r0 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r1 = value_range (INT (6), INT (35));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == range_union (value_range (INT (6), INT (40)),
-				      value_range (INT (50), INT (60))));
-
-      // [10,20][30,40][50,60] U [6,60] => [6,60].
-      r0 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r1 = value_range (INT (6), INT (60));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == value_range (INT (6), INT (60)));
-
-      // [10,20][30,40][50,60] U [6,70] => [6,70].
-      r0 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r1 = value_range (INT (6), INT (70));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == value_range (INT (6), INT (70)));
-
-      // [10,20][30,40][50,60] U [35,70] => [10,20][30,70].
-      r0 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r1 = value_range (INT (35), INT (70));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
-				      value_range (INT (30), INT (70))));
-    }
-
   // [10,20][30,40] U [25,70] => [10,70].
   r0 = range_union (value_range (INT (10), INT (20)),
 		     value_range (INT (30), INT (40)));
@@ -3129,16 +3057,6 @@  range_tests ()
   ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
 				  value_range (INT (25), INT (70))));
 
-  if (value_range::m_max_pairs > 2)
-    {
-      // [10,20][30,40][50,60] U [15,35] => [10,40][50,60].
-      r0 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r1 = value_range (INT (15), INT (35));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (40)),
-				      value_range (INT (50), INT (60))));
-    }
-
   // [10,20] U [15, 30] => [10, 30].
   r0 = value_range (INT (10), INT (20));
   r1 = value_range (INT (15), INT (30));
@@ -3152,15 +3070,6 @@  range_tests ()
   ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
 				  value_range (INT (25), INT (25))));
 
-  if (value_range::m_max_pairs > 2)
-    {
-      // [10,20][30,40][50,60] U [35,35] => [10,20][30,40][50,60].
-      r0 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r1 = value_range (INT (35), INT (35));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == RANGE3 (10, 20, 30, 40, 50, 60));
-    }
-
   // [15,40] U [] => [15,40].
   r0 = value_range (INT (15), INT (40));
   r1.set_undefined ();
@@ -3179,61 +3088,6 @@  range_tests ()
   r0.union_ (r1);
   ASSERT_TRUE (r0 == value_range (INT (9), INT (20)));
 
-  if (value_range::m_max_pairs > 2)
-    {
-      // [10,10][12,12][20,100] ^ [15,200].
-      r0 = RANGE3 (10, 10, 12, 12, 20, 100);
-      r1 = value_range (INT (15), INT (200));
-      r0.intersect (r1);
-      ASSERT_TRUE (r0 == value_range (INT (20), INT (100)));
-
-      // [10,20][30,40][50,60] ^ [15,25][38,51][55,70]
-      // => [15,20][38,40][50,51][55,60]
-      r0 = RANGE3 (10, 20, 30, 40, 50, 60);
-      r1 = RANGE3 (15, 25, 38, 51, 55, 70);
-      r0.intersect (r1);
-      if (value_range::m_max_pairs == 3)
-	{
-	  // When pairs==3, we don't have enough space, so
-	  //  conservatively handle things.  Thus, the ...[50,60].
-	  ASSERT_TRUE (r0 == RANGE3 (15, 20, 38, 40, 50, 60));
-	}
-      else
-	{
-	  r2 = RANGE3 (15, 20, 38, 40, 50, 51);
-	  r2.union_ (value_range (INT (55), INT (60)));
-	  ASSERT_TRUE (r0 == r2);
-	}
-
-      // [15,20][30,40][50,60] ^ [15,35][40,90][100,200]
-      // => [15,20][30,35][40,60]
-      r0 = RANGE3 (15, 20, 30, 40, 50, 60);
-      r1 = RANGE3 (15, 35, 40, 90, 100, 200);
-      r0.intersect (r1);
-      if (value_range::m_max_pairs == 3)
-	{
-	  // When pairs==3, we don't have enough space, so
-	  // conservatively handle things.
-	  ASSERT_TRUE (r0 == RANGE3 (15, 20, 30, 35, 40, 60));
-	}
-      else
-	{
-	  r2 = RANGE3 (15, 20, 30, 35, 40, 40);
-	  r2.union_ (value_range (INT (50), INT (60)));
-	  ASSERT_TRUE (r0 == r2);
-	}
-
-      // Test cases where a union inserts a sub-range inside a larger
-      // range.
-      //
-      // [8,10][135,255] U [14,14] => [8,10][14,14][135,255]
-      r0 = range_union (value_range (INT (8), INT (10)),
-			 value_range (INT (135), INT (255)));
-      r1 = value_range (INT (14), INT (14));
-      r0.union_ (r1);
-      ASSERT_TRUE (r0 == RANGE3 (8, 10, 14, 14, 135, 255));
-    }
-
   // [10,20] ^ [15,30] => [15,20].
   r0 = value_range (INT (10), INT (20));
   r1 = value_range (INT (15), INT (30));
@@ -3267,4 +3121,7 @@  range_tests ()
   r0.invert ();
   ASSERT_TRUE (r0.nonzero_p ());
 }
+
+} // namespace selftest
+
 #endif // CHECKING_P
diff --git a/gcc/selftest.h b/gcc/selftest.h
index cc7212317c3..48d848067cf 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -237,6 +237,7 @@  extern void opt_problem_cc_tests ();
 extern void optinfo_emit_json_cc_tests ();
 extern void predict_c_tests ();
 extern void pretty_print_c_tests ();
+extern void range_tests ();
 extern void read_rtl_function_c_tests ();
 extern void rtl_tests_c_tests ();
 extern void sbitmap_c_tests ();
@@ -260,10 +261,6 @@  extern int num_passes;
 
 } /* end of namespace selftest.  */
 
-/* This is outside of the selftest namespace because it's a friend of
-   value_range.  */
-extern void range_tests ();
-
 /* Macros for writing tests.  */
 
 /* Evaluate EXPR and coerce to bool, calling
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 23b05b4be91..5a6cb5236e1 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -39,7 +39,6 @@  enum value_range_kind
 
 class GTY((for_user)) value_range
 {
-  friend void range_tests ();
 public:
   value_range ();
   value_range (tree, tree, value_range_kind = VR_RANGE);