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

commit r15-353-gd7bb8eaade3cd3aa70715c8567b4d7b08098e699
Author: Aldy Hernandez <al...@redhat.com>
Date:   Fri May 10 00:29:13 2024 +0200

    Revert: "Enable prange support." [PR114985]
    
    This reverts commit 36e877996936abd8bd08f8b1d983c8d1023a5842 until the IPA
    pass is fixed with regards to POINTER = POINTER <RELOP> POINTER.

Diff:
---
 gcc/gimple-range-cache.cc     |  4 ++--
 gcc/gimple-range-fold.cc      |  4 ++--
 gcc/gimple-range-fold.h       |  2 +-
 gcc/gimple-range-infer.cc     |  2 +-
 gcc/gimple-range-op.cc        |  2 +-
 gcc/gimple-range-path.cc      |  2 +-
 gcc/gimple-ssa-warn-access.cc |  2 +-
 gcc/ipa-cp.h                  |  2 +-
 gcc/range-op-ptr.cc           |  4 ++++
 gcc/range-op.cc               | 18 ++++++++++++++----
 gcc/tree-ssa-structalias.cc   |  2 +-
 gcc/value-range.cc            |  1 -
 gcc/value-range.h             |  4 ++--
 13 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index bdd2832873aa..72ac25523117 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -274,10 +274,10 @@ sbr_sparse_bitmap::sbr_sparse_bitmap (tree t, 
vrange_allocator *allocator,
   // Pre-cache zero and non-zero values for pointers.
   if (POINTER_TYPE_P (t))
     {
-      prange nonzero;
+      int_range<2> nonzero;
       nonzero.set_nonzero (t);
       m_range[1] = m_range_allocator->clone (nonzero);
-      prange zero;
+      int_range<2> zero;
       zero.set_zero (t);
       m_range[2] = m_range_allocator->clone (zero);
     }
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index a9c8c4d03e63..9c4ad1ee7b91 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -597,7 +597,7 @@ fold_using_range::fold_stmt (vrange &r, gimple *s, 
fur_source &src, tree name)
   // Process addresses.
   if (gimple_code (s) == GIMPLE_ASSIGN
       && gimple_assign_rhs_code (s) == ADDR_EXPR)
-    return range_of_address (as_a <prange> (r), s, src);
+    return range_of_address (as_a <irange> (r), s, src);
 
   gimple_range_op_handler handler (s);
   if (handler)
@@ -757,7 +757,7 @@ fold_using_range::range_of_range_op (vrange &r,
 // If a range cannot be calculated, set it to VARYING and return true.
 
 bool
-fold_using_range::range_of_address (prange &r, gimple *stmt, fur_source &src)
+fold_using_range::range_of_address (irange &r, gimple *stmt, fur_source &src)
 {
   gcc_checking_assert (gimple_code (stmt) == GIMPLE_ASSIGN);
   gcc_checking_assert (gimple_assign_rhs_code (stmt) == ADDR_EXPR);
diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h
index c7c599bfc939..7cbe15d05e53 100644
--- a/gcc/gimple-range-fold.h
+++ b/gcc/gimple-range-fold.h
@@ -157,7 +157,7 @@ protected:
                          fur_source &src);
   bool range_of_call (vrange &r, gcall *call, fur_source &src);
   bool range_of_cond_expr (vrange &r, gassign* cond, fur_source &src);
-  bool range_of_address (prange &r, gimple *s, fur_source &src);
+  bool range_of_address (irange &r, gimple *s, fur_source &src);
   bool range_of_phi (vrange &r, gphi *phi, fur_source &src);
   void range_of_ssa_name_with_loop_info (vrange &, tree, class loop *, gphi *,
                                         fur_source &src);
diff --git a/gcc/gimple-range-infer.cc b/gcc/gimple-range-infer.cc
index d5e1aa142758..c8e8b9b60ac1 100644
--- a/gcc/gimple-range-infer.cc
+++ b/gcc/gimple-range-infer.cc
@@ -123,7 +123,7 @@ gimple_infer_range::add_nonzero (tree name)
 {
   if (!gimple_range_ssa_p (name))
     return;
-  prange nz;
+  int_range<2> nz;
   nz.set_nonzero (TREE_TYPE (name));
   add_range (name, nz);
 }
diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
index ddd13ec55942..55dfbb23ce22 100644
--- a/gcc/gimple-range-op.cc
+++ b/gcc/gimple-range-op.cc
@@ -1120,7 +1120,7 @@ class cfn_strlen : public range_operator
 {
 public:
   using range_operator::fold_range;
-  virtual bool fold_range (irange &r, tree type, const prange &,
+  virtual bool fold_range (irange &r, tree type, const irange &,
                           const irange &, relation_trio) const
   {
     wide_int max = irange_val_max (ptrdiff_type_node);
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index f1a12f76144c..96c6ac6b6a50 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -443,7 +443,7 @@ path_range_query::compute_ranges_in_block (basic_block bb)
 void
 path_range_query::adjust_for_non_null_uses (basic_block bb)
 {
-  prange r;
+  int_range_max r;
   bitmap_iterator bi;
   unsigned i;
 
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index 0cd5b6d6ef48..2c10d19e7f36 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -4213,7 +4213,7 @@ pass_waccess::check_pointer_uses (gimple *stmt, tree ptr,
                 where the realloc call is known to have failed are valid.
                 Ignore pointers that nothing is known about.  Those could
                 have escaped along with their nullness.  */
-             prange vr;
+             value_range vr;
              if (m_ptr_qry.rvals->range_of_expr (vr, realloc_lhs, use_stmt))
                {
                  if (vr.zero_p ())
diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h
index e62a09f38af6..abeaaa4053e1 100644
--- a/gcc/ipa-cp.h
+++ b/gcc/ipa-cp.h
@@ -296,7 +296,7 @@ bool values_equal_for_ipcp_p (tree x, tree y);
 static inline bool
 ipa_supports_p (tree type)
 {
-  return irange::supports_p (type) || prange::supports_p (type);
+  return irange::supports_p (type);
 }
 
 #endif /* IPA_CP_H */
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 4d5cbda764ca..466edc6bf746 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -1968,4 +1968,8 @@ range_op_table::initialize_pointer_ops ()
 {
   set (POINTER_PLUS_EXPR, op_pointer_plus);
   set (POINTER_DIFF_EXPR, op_pointer_diff);
+  set (BIT_AND_EXPR, op_hybrid_and);
+  set (BIT_IOR_EXPR, op_hybrid_or);
+  set (MIN_EXPR, op_hybrid_min);
+  set (MAX_EXPR, op_hybrid_max);
 }
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index e00136479a6d..a134af68141e 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -102,13 +102,23 @@ range_op_table::range_op_table ()
   set (MINUS_EXPR, op_minus);
   set (NEGATE_EXPR, op_negate);
   set (MULT_EXPR, op_mult);
+
+  // Occur in both integer and pointer tables, but currently share
+  // integral implementation.
   set (ADDR_EXPR, op_addr);
   set (BIT_NOT_EXPR, op_bitwise_not);
   set (BIT_XOR_EXPR, op_bitwise_xor);
-  set (BIT_AND_EXPR, op_bitwise_and);
-  set (BIT_IOR_EXPR, op_bitwise_or);
-  set (MIN_EXPR, op_min);
-  set (MAX_EXPR, op_max);
+
+  // These are in both integer and pointer tables, but pointer has a different
+  // implementation.
+  // If commented out, there is a hybrid version in range-op-ptr.cc which
+  // is used until there is a pointer range class.  Then we can simply
+  // uncomment the operator here and use the unified version.
+
+  // set (BIT_AND_EXPR, op_bitwise_and);
+  // set (BIT_IOR_EXPR, op_bitwise_or);
+  // set (MIN_EXPR, op_min);
+  // set (MAX_EXPR, op_max);
 }
 
 // Instantiate a default range operator for opcodes with no entry.
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index bb59c6a7c023..9c63305063c1 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -6833,7 +6833,7 @@ find_what_p_points_to (tree fndecl, tree p)
   struct ptr_info_def *pi;
   tree lookup_p = p;
   varinfo_t vi;
-  prange vr;
+  value_range vr;
   get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p);
   bool nonnull = vr.nonzero_p ();
 
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index ada941bf3b5b..3e1ecf69517c 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -1518,7 +1518,6 @@ irange::verify_range ()
       gcc_checking_assert (m_num_ranges == 0);
       return;
     }
-  gcc_checking_assert (supports_p (type ()));
   gcc_checking_assert (m_num_ranges <= m_max_ranges);
 
   // Legacy allowed these to represent VARYING for unknown types.
diff --git a/gcc/value-range.h b/gcc/value-range.h
index 44cdbd717f4c..37ce91dc52d1 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -994,7 +994,7 @@ irange::varying_compatible_p () const
   const wide_int &u = m_base[1];
   tree t = m_type;
 
-  if (m_kind == VR_VARYING)
+  if (m_kind == VR_VARYING && t == error_mark_node)
     return true;
 
   unsigned prec = TYPE_PRECISION (t);
@@ -1039,7 +1039,7 @@ irange::nonzero_p () const
 inline bool
 irange::supports_p (const_tree type)
 {
-  return INTEGRAL_TYPE_P (type);
+  return INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type);
 }
 
 inline bool

Reply via email to