public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jiu Fu Guo <guojiufu@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4655] use more get_range_query
Date: Mon, 16 Oct 2023 07:35:01 +0000 (GMT)	[thread overview]
Message-ID: <20231016073501.1E35D3858D33@sourceware.org> (raw)

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

commit r14-4655-gb7a28c0904fa67f98d7ca7e9d828fc5fc58c7078
Author: Jiufu Guo <guojiufu@linux.ibm.com>
Date:   Mon Oct 16 15:28:52 2023 +0800

    use more get_range_query
    
    For "get_global_range_query" SSA_NAME_RANGE_INFO can be queried.
    For "get_range_query", it could get more context-aware range info.
    And look at the implementation of "get_range_query",  it returns
    global range if no local fun info.
    
    So, if not quering for SSA_NAME and not chaning the IL, it would
    be ok to use get_range_query to replace get_global_range_query.
    
    gcc/ChangeLog:
    
            * fold-const.cc (expr_not_equal_to): Replace get_global_range_query
            by get_range_query.
            * gimple-fold.cc (size_must_be_zero_p): Likewise.
            * gimple-range-fold.cc (fur_source::fur_source): Likewise.
            * gimple-ssa-warn-access.cc (check_nul_terminated_array): Likewise.
            * tree-dfa.cc (get_ref_base_and_extent): Likewise.

Diff:
---
 gcc/fold-const.cc             | 6 +-----
 gcc/gimple-fold.cc            | 6 ++----
 gcc/gimple-range-fold.cc      | 4 +---
 gcc/gimple-ssa-warn-access.cc | 2 +-
 gcc/tree-dfa.cc               | 5 +----
 5 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 0b6bd376a06..44118e799eb 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -11064,11 +11064,7 @@ expr_not_equal_to (tree t, const wide_int &w)
       if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
 	return false;
 
-      if (cfun)
-	get_range_query (cfun)->range_of_expr (vr, t);
-      else
-	get_global_range_query ()->range_of_expr (vr, t);
-
+      get_range_query (cfun)->range_of_expr (vr, t);
       if (!vr.undefined_p () && !vr.contains_p (w))
 	return true;
       /* If T has some known zero bits and W has any of those bits set,
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index dc89975270c..853edd9e5d4 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -876,10 +876,8 @@ size_must_be_zero_p (tree size)
   wide_int zero = wi::zero (TYPE_PRECISION (type));
   value_range valid_range (type, zero, ssize_max);
   value_range vr;
-  if (cfun)
-    get_range_query (cfun)->range_of_expr (vr, size);
-  else
-    get_global_range_query ()->range_of_expr (vr, size);
+  get_range_query (cfun)->range_of_expr (vr, size);
+
   if (vr.undefined_p ())
     vr.set_varying (TREE_TYPE (size));
   vr.intersect (valid_range);
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index d1945ccb554..6e9530c3d7f 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -50,10 +50,8 @@ fur_source::fur_source (range_query *q)
 {
   if (q)
     m_query = q;
-  else if (cfun)
-    m_query = get_range_query (cfun);
   else
-    m_query = get_global_range_query ();
+    m_query = get_range_query (cfun);
   m_gori = NULL;
 }
 
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index fcaff128d60..e439d1b9b68 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -332,7 +332,7 @@ check_nul_terminated_array (GimpleOrTree expr, tree src, tree bound)
     {
       Value_Range r (TREE_TYPE (bound));
 
-      get_global_range_query ()->range_of_expr (r, bound);
+      get_range_query (cfun)->range_of_expr (r, bound);
 
       if (r.undefined_p () || r.varying_p ())
 	return true;
diff --git a/gcc/tree-dfa.cc b/gcc/tree-dfa.cc
index af8e9243947..5355af2c869 100644
--- a/gcc/tree-dfa.cc
+++ b/gcc/tree-dfa.cc
@@ -531,10 +531,7 @@ get_ref_base_and_extent (tree exp, poly_int64 *poffset,
 
 		value_range vr;
 		range_query *query;
-		if (cfun)
-		  query = get_range_query (cfun);
-		else
-		  query = get_global_range_query ();
+		query = get_range_query (cfun);
 
 		if (TREE_CODE (index) == SSA_NAME
 		    && (low_bound = array_ref_low_bound (exp),

                 reply	other threads:[~2023-10-16  7:35 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=20231016073501.1E35D3858D33@sourceware.org \
    --to=guojiufu@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).