Make irange::intersect(wide_int, wide_int) private.
authorAldy Hernandez <aldyh@redhat.com>
Mon, 7 Mar 2022 13:48:58 +0000 (14:48 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Fri, 29 Apr 2022 08:41:59 +0000 (10:41 +0200)
This method should have been private, and somehow seeped into the API.

Tested and benchmarked on x86-64 Linux.

gcc/ChangeLog:

* gimple-range-cache.h (non_null_ref::adjust_range): Do not use
irange::intersect (wide_int, wide_int).
* gimple-range-fold.cc (adjust_pointer_diff_expr): Same.
(adjust_imagpart_expr): Same.
* value-range.h (irange::intersect (wide_int, wide_int)): Make
private.

gcc/gimple-range-cache.h
gcc/gimple-range-fold.cc
gcc/value-range.h

index 589b649..a0244e4 100644 (file)
@@ -64,8 +64,10 @@ non_null_ref::adjust_range (irange &r, tree name, basic_block bb,
   if (non_null_deref_p (name, bb, search_dom))
     {
       // Remove zero from the range.
-      unsigned prec = TYPE_PRECISION (TREE_TYPE (name));
-      r.intersect (wi::one (prec), wi::max_value (prec, UNSIGNED));
+      gcc_checking_assert (TYPE_UNSIGNED (TREE_TYPE (name)));
+      int_range<2> nz;
+      nz.set_nonzero (TREE_TYPE (name));
+      r.intersect (nz);
       return true;
     }
   return false;
index dfacf6f..3169e29 100644 (file)
@@ -362,7 +362,7 @@ adjust_pointer_diff_expr (irange &res, const gimple *diff_stmt)
       tree max = vrp_val_max (ptrdiff_type_node);
       unsigned prec = TYPE_PRECISION (TREE_TYPE (max));
       wide_int wmaxm1 = wi::to_wide (max, prec) - 1;
-      res.intersect (wi::zero (prec), wmaxm1);
+      res.intersect (int_range<2> (TREE_TYPE (max), wi::zero (prec), wmaxm1));
     }
 }
 
@@ -403,8 +403,8 @@ adjust_imagpart_expr (irange &res, const gimple *stmt)
       tree cst = gimple_assign_rhs1 (def_stmt);
       if (TREE_CODE (cst) == COMPLEX_CST)
        {
-         wide_int imag = wi::to_wide (TREE_IMAGPART (cst));
-         res.intersect (imag, imag);
+         int_range<2> imag (TREE_IMAGPART (cst), TREE_IMAGPART (cst));
+         res.intersect (imag);
        }
     }
 }
index d4cba22..fe7795b 100644 (file)
@@ -73,7 +73,6 @@ public:
   // In-place operators.
   void union_ (const irange &);
   void intersect (const irange &);
-  void intersect (const wide_int& lb, const wide_int& ub);
   void invert ();
 
   // Operator overloads.
@@ -135,6 +134,7 @@ private:
   void irange_set_1bit_anti_range (tree, tree);
   bool varying_compatible_p () const;
 
+  void intersect (const wide_int& lb, const wide_int& ub);
   unsigned char m_num_ranges;
   unsigned char m_max_ranges;
   ENUM_BITFIELD(value_range_kind) m_kind : 8;