public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1080] Cleanup get_range_info
@ 2021-05-26 19:32 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-05-26 19:32 UTC (permalink / raw)
  To: gcc-cvs

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

commit r12-1080-gaf66d0af87cf36d923d4663935a2b7a682753a24
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu May 20 12:23:49 2021 +0200

    Cleanup get_range_info
    
    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.

Diff:
---
 gcc/tree-ssanames.c | 57 +++++++++++++----------------------------------------
 gcc/tree-ssanames.h |  2 --
 2 files changed, 14 insertions(+), 45 deletions(-)

diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index 51a26d2fce1..5329c0a4187 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -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.  */
diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h
index cce2d2c22e8..166f921f04c 100644
--- a/gcc/tree-ssanames.h
+++ b/gcc/tree-ssanames.h
@@ -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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-26 19:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 19:32 [gcc r12-1080] Cleanup get_range_info Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).