public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-1080] Cleanup get_range_info
Date: Wed, 26 May 2021 19:32:03 +0000 (GMT)	[thread overview]
Message-ID: <20210526193203.0A6F6384783B@sourceware.org> (raw)

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);


                 reply	other threads:[~2021-05-26 19:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210526193203.0A6F6384783B@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).