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 r13-1463] Misc conversions to vrange.
Date: Mon,  4 Jul 2022 18:45:53 +0000 (GMT)	[thread overview]
Message-ID: <20220704184553.5C1043854148@sourceware.org> (raw)

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

commit r13-1463-gce8dbe7d834b9264d7a5cd74d3ce6c750d28b3af
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Mon Jul 4 17:32:07 2022 +0200

    Misc conversions to vrange.
    
    The following converts a handful of places that were irange centric.
    
    Tested on x86-64 Linux.
    
    gcc/ChangeLog:
    
            * gimple-range-fold.cc
            (fold_using_range::range_of_ssa_name_with_loop_info): Restrict the
            call to SCEV for irange supported types.
            (fold_using_range::range_of_builtin_int_call): Convert to vrange.
            * gimple-range.cc (gimple_ranger::prefill_stmt_dependencies): Same.
            * tree-ssa-dom.cc (cprop_operand): Same.

Diff:
---
 gcc/gimple-range-fold.cc | 32 ++++++++++++++++++--------------
 gcc/gimple-range.cc      | 11 ++++++++---
 gcc/tree-ssa-dom.cc      |  2 +-
 3 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 0f815b50b9a..6f907df5bf5 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -1006,19 +1006,21 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call,
   switch (func)
     {
     case CFN_BUILT_IN_CONSTANT_P:
-      arg = gimple_call_arg (call, 0);
-      if (src.get_operand (r, arg) && r.singleton_p ())
-	{
-	  r.set (build_one_cst (type), build_one_cst (type));
-	  return true;
-	}
-      if (cfun->after_inlining)
-	{
-	  r.set_zero (type);
-	  // r.equiv_clear ();
-	  return true;
-	}
-      break;
+      {
+	arg = gimple_call_arg (call, 0);
+	Value_Range tmp (TREE_TYPE (arg));
+	if (src.get_operand (tmp, arg) && tmp.singleton_p ())
+	  {
+	    r.set (build_one_cst (type), build_one_cst (type));
+	    return true;
+	  }
+	if (cfun->after_inlining)
+	  {
+	    r.set_zero (type);
+	    return true;
+	  }
+	break;
+      }
 
     case CFN_BUILT_IN_TOUPPER:
       {
@@ -1335,7 +1337,9 @@ fold_using_range::range_of_ssa_name_with_loop_info (irange &r, tree name,
 {
   gcc_checking_assert (TREE_CODE (name) == SSA_NAME);
   tree min, max, type = TREE_TYPE (name);
-  if (bounds_of_var_in_loop (&min, &max, src.query (), l, phi, name))
+  // FIXME: Remove the supports_p() once all this can handle floats, etc.
+  if (irange::supports_p (type)
+      && bounds_of_var_in_loop (&min, &max, src.query (), l, phi, name))
     {
       if (TREE_CODE (min) != INTEGER_CST)
 	{
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index f3a46555f91..3a9f0b07e79 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -422,12 +422,17 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa)
 	{
 	  gcc_checking_assert (range_op_handler (stmt));
 	  tree op = gimple_range_operand2 (stmt);
-	  Value_Range r (TREE_TYPE (name));
 	  if (op)
-	    prefill_name (r, op);
+	    {
+	      Value_Range r (TREE_TYPE (op));
+	      prefill_name (r, op);
+	    }
 	  op = gimple_range_operand1 (stmt);
 	  if (op)
-	    prefill_name (r, op);
+	    {
+	      Value_Range r (TREE_TYPE (op));
+	      prefill_name (r, op);
+	    }
 	}
     }
   if (idx)
diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc
index 9b6520fd2dd..2bc2c3db7d7 100644
--- a/gcc/tree-ssa-dom.cc
+++ b/gcc/tree-ssa-dom.cc
@@ -1837,7 +1837,7 @@ cprop_operand (gimple *stmt, use_operand_p op_p, range_query *query)
   val = SSA_NAME_VALUE (op);
   if (!val)
     {
-      int_range<2> r;
+      Value_Range r (TREE_TYPE (op));
       tree single;
       if (query->range_of_expr (r, op, stmt) && r.singleton_p (&single))
 	val = single;


                 reply	other threads:[~2022-07-04 18:45 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=20220704184553.5C1043854148@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).