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(refs/users/aldyh/heads/ranger-relational)] Resolve symbolics in loop info results.
Date: Wed, 21 Apr 2021 17:19:26 +0000 (GMT)	[thread overview]
Message-ID: <20210421171926.AA7D13838001@sourceware.org> (raw)

https://gcc.gnu.org/g:9fc92dea23701792630d86a0c85d1356243ba7a0

commit 9fc92dea23701792630d86a0c85d1356243ba7a0
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed Apr 21 17:33:33 2021 +0200

    Resolve symbolics in loop info results.

Diff:
---
 gcc/gimple-range-fold.cc | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index c8104058796..5d62bd62682 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -886,13 +886,22 @@ fold_using_range::range_of_ssa_name_with_loop_info (irange &r, tree name,
   tree min, max, type = TREE_TYPE (name);
   if (bounds_of_var_in_loop (&min, &max, &(src.m_query), l, phi, name))
     {
-      // ?? We could do better here.  Since MIN/MAX can only be an
-      // SSA, SSA +- INTEGER_CST, or INTEGER_CST, we could easily call
-      // the ranger and solve anything not an integer.
       if (TREE_CODE (min) != INTEGER_CST)
-	min = vrp_val_min (type);
+	{
+	  src.m_query.range_of_expr (r, min, phi);
+	  if (r.undefined_p ())
+	    min = vrp_val_min (type);
+	  else
+	    min = wide_int_to_tree (type, r.lower_bound ());
+	}
       if (TREE_CODE (max) != INTEGER_CST)
-	max = vrp_val_max (type);
+	{
+	  src.m_query.range_of_expr (r, max, phi);
+	  if (r.undefined_p ())
+	    max = vrp_val_max (type);
+	  else
+	    max = wide_int_to_tree (type, r.upper_bound ());
+	}
       r.set (min, max);
     }
   else


                 reply	other threads:[~2021-04-21 17:19 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=20210421171926.AA7D13838001@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).