]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert "Revert: "Enable prange support.""
authorAldy Hernandez <aldyh@redhat.com>
Thu, 9 May 2024 22:38:51 +0000 (00:38 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Thu, 16 May 2024 09:59:08 +0000 (11:59 +0200)
This reverts commit d7bb8eaade3cd3aa70715c8567b4d7b08098e699 and enables prange
support again.

13 files changed:
gcc/gimple-range-cache.cc
gcc/gimple-range-fold.cc
gcc/gimple-range-fold.h
gcc/gimple-range-infer.cc
gcc/gimple-range-op.cc
gcc/gimple-range-path.cc
gcc/gimple-ssa-warn-access.cc
gcc/ipa-cp.h
gcc/range-op-ptr.cc
gcc/range-op.cc
gcc/tree-ssa-structalias.cc
gcc/value-range.cc
gcc/value-range.h

index 72ac255231172c903f573758bfb0a4056768b95a..bdd2832873aa973ed028f22267929cdab2a7d52c 100644 (file)
@@ -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))
     {
-      int_range<2> nonzero;
+      prange nonzero;
       nonzero.set_nonzero (t);
       m_range[1] = m_range_allocator->clone (nonzero);
-      int_range<2> zero;
+      prange zero;
       zero.set_zero (t);
       m_range[2] = m_range_allocator->clone (zero);
     }
index 9c4ad1ee7b910153f36b6b765e9f8e1435ffc952..a9c8c4d03e631d963c100637149287921cdc45b0 100644 (file)
@@ -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 <irange> (r), s, src);
+    return range_of_address (as_a <prange> (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 (irange &r, gimple *stmt, fur_source &src)
+fold_using_range::range_of_address (prange &r, gimple *stmt, fur_source &src)
 {
   gcc_checking_assert (gimple_code (stmt) == GIMPLE_ASSIGN);
   gcc_checking_assert (gimple_assign_rhs_code (stmt) == ADDR_EXPR);
index 7cbe15d05e5310e1ac3c5633a378f4058783fc7d..c7c599bfc939171d31c65e25aa5459ec6abd2926 100644 (file)
@@ -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 (irange &r, gimple *s, fur_source &src);
+  bool range_of_address (prange &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);
index c8e8b9b60ac1bb69accd10e6aec8453f6dadef66..d5e1aa142758a9bc539d22c38c2535a0a71e8f49 100644 (file)
@@ -123,7 +123,7 @@ gimple_infer_range::add_nonzero (tree name)
 {
   if (!gimple_range_ssa_p (name))
     return;
-  int_range<2> nz;
+  prange nz;
   nz.set_nonzero (TREE_TYPE (name));
   add_range (name, nz);
 }
index 7321342b00de10ef694851909198fc46d417ef58..aec3f39ec0e86e7fa00cea1eab602eb1db5c5f9d 100644 (file)
@@ -1107,7 +1107,7 @@ class cfn_strlen : public range_operator
 {
 public:
   using range_operator::fold_range;
-  virtual bool fold_range (irange &r, tree type, const irange &,
+  virtual bool fold_range (irange &r, tree type, const prange &,
                           const irange &, relation_trio) const
   {
     wide_int max = irange_val_max (ptrdiff_type_node);
index 96c6ac6b6a5020107a7194ad9fd855d291f4bb7e..f1a12f76144cc4c89d5690b2f7574545e6aea25e 100644 (file)
@@ -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)
 {
-  int_range_max r;
+  prange r;
   bitmap_iterator bi;
   unsigned i;
 
index 2c10d19e7f36ec030eab3d22151eb62659d2be56..0cd5b6d6ef48532b4957333c186b3145d6e2e362 100644 (file)
@@ -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.  */
-             value_range vr;
+             prange vr;
              if (m_ptr_qry.rvals->range_of_expr (vr, realloc_lhs, use_stmt))
                {
                  if (vr.zero_p ())
index abeaaa4053e190cf8645a8be27607115a34555bb..e62a09f38af6d46e7577c81074e6e0bd1955ccbf 100644 (file)
@@ -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);
+  return irange::supports_p (type) || prange::supports_p (type);
 }
 
 #endif /* IPA_CP_H */
index c24097a1c30983c5cf030e48e0893246b35b5eb7..9421d3cd21d0af5ac6ecb84c8c585079e32ffc38 100644 (file)
@@ -1684,8 +1684,4 @@ 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);
 }
index 852d59c20e9e2f677bbacd1872eb719bb3090ed4..d188d1a1b63a6ff6a18a642b1ce145b665277c7c 100644 (file)
@@ -102,23 +102,13 @@ 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);
-
-  // 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);
+  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.
index 9c63305063c11753e952d164276572831219dbc6..bb59c6a7c0236267b1f3ca05c9dde081156dd855 100644 (file)
@@ -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;
-  value_range vr;
+  prange vr;
   get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p);
   bool nonnull = vr.nonzero_p ();
 
index 5bcb2c3f650be59bbe6a53d77d2129b6016664cb..334ffb70fbc2c8d01491d36bf73e701820a98809 100644 (file)
@@ -1518,6 +1518,7 @@ 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.
index 37ce91dc52d1c10297a19cf9b0293c0eb9309f87..44cdbd717f4c5f38e5f51924351ce125d18dedf6 100644 (file)
@@ -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 && t == error_mark_node)
+  if (m_kind == VR_VARYING)
     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) || POINTER_TYPE_P (type);
+  return INTEGRAL_TYPE_P (type);
 }
 
 inline bool