]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Cleanup get_range_info
authorAldy Hernandez <aldyh@redhat.com>
Thu, 20 May 2021 10:23:49 +0000 (12:23 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 26 May 2021 19:31:27 +0000 (21:31 +0200)
Now that there is only one user of get_range_info() we can clean this up
to always return a range instead of pairs of wide_ints.

A follow-up patch will inline both get_range_info and get_ptr_nonnull
into its only remaining user.

gcc/ChangeLog:

* tree-ssanames.c (get_range_info): Merge both copies of
get_range_info into one that works with irange.
* tree-ssanames.h (get_range_info): Remove version that works on
wide_ints.

gcc/tree-ssanames.c
gcc/tree-ssanames.h

index 51a26d2fce1c25b1557b3adfc585383eb515a023..5329c0a418768e0ecdedb42da06bceaf0014ef70 100644 (file)
@@ -423,58 +423,29 @@ set_range_info (tree name, const value_range &vr)
   set_range_info (name, vr.kind (), min, max);
 }
 
-/* Gets range information MIN, MAX and returns enum value_range_kind
-   corresponding to tree ssa_name NAME.  enum value_range_kind returned
-   is used to determine if MIN and MAX are valid values.  */
+/* Gets range information corresponding to ssa_name NAME and stores it
+   in a value_range VR.  Returns the value_range_kind.  */
 
 enum value_range_kind
-get_range_info (const_tree expr, wide_int *min, wide_int *max)
+get_range_info (const_tree name, irange &vr)
 {
-  gcc_assert (!POINTER_TYPE_P (TREE_TYPE (expr)));
-  gcc_assert (min && max);
-  if (TREE_CODE (expr) == INTEGER_CST)
-    {
-      *min = wi::to_wide (expr);
-      *max = *min;
-      return VR_RANGE;
-    }
-  if (TREE_CODE (expr) != SSA_NAME)
-    return VR_VARYING;
+  tree type = TREE_TYPE (name);
+  gcc_checking_assert (!POINTER_TYPE_P (type));
+  gcc_checking_assert (TREE_CODE (name) == SSA_NAME);
 
-  range_info_def *ri = SSA_NAME_RANGE_INFO (expr);
+  range_info_def *ri = SSA_NAME_RANGE_INFO (name);
 
   /* Return VR_VARYING for SSA_NAMEs with NULL RANGE_INFO or SSA_NAMEs
      with integral types width > 2 * HOST_BITS_PER_WIDE_INT precision.  */
-  if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (expr)))
+  if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (name)))
              > 2 * HOST_BITS_PER_WIDE_INT))
-    return VR_VARYING;
-
-  *min = ri->get_min ();
-  *max = ri->get_max ();
-  return SSA_NAME_RANGE_TYPE (expr);
-}
-
-/* Gets range information corresponding to ssa_name NAME and stores it
-   in a value_range VR.  Returns the value_range_kind.  */
-
-enum value_range_kind
-get_range_info (const_tree name, irange &vr)
-{
-  tree min, max;
-  wide_int wmin, wmax;
-  enum value_range_kind kind = get_range_info (name, &wmin, &wmax);
-
-  if (kind == VR_VARYING)
-    vr.set_varying (TREE_TYPE (name));
-  else if (kind == VR_UNDEFINED)
-    vr.set_undefined ();
+    vr.set_varying (type);
   else
-    {
-      min = wide_int_to_tree (TREE_TYPE (name), wmin);
-      max = wide_int_to_tree (TREE_TYPE (name), wmax);
-      vr.set (min, max, kind);
-    }
-  return kind;
+    vr.set (wide_int_to_tree (type, ri->get_min ()),
+           wide_int_to_tree (type, ri->get_max ()),
+           SSA_NAME_RANGE_TYPE (name));
+
+  return vr.kind ();
 }
 
 /* Set nonnull attribute to pointer NAME.  */
index cce2d2c22e8cf1ed538090c2f71c42a00e3fffb4..166f921f04cbbd3c4ae43b71797077361cc3d754 100644 (file)
@@ -71,8 +71,6 @@ extern void set_range_info (tree, enum value_range_kind, const wide_int_ref &,
                            const wide_int_ref &);
 extern void set_range_info (tree, const value_range &);
 /* Gets the value range from SSA.  */
-extern enum value_range_kind get_range_info (const_tree, wide_int *,
-                                            wide_int *);
 extern enum value_range_kind get_range_info (const_tree, irange &);
 extern void set_nonzero_bits (tree, const wide_int_ref &);
 extern wide_int get_nonzero_bits (const_tree);