public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Subject: [COMMITTED] Make the path solver's range_of_stmt() handle all statements.
Date: Sun,  5 Sep 2021 18:11:54 +0200	[thread overview]
Message-ID: <20210905161154.848779-1-aldyh@redhat.com> (raw)

The path solver's range_of_stmt() was handcuffed to only fold
GIMPLE_COND statements, since those were the only statements the
backward threader needed to resolve.  However, there is no need for this
restriction, as the folding code is perfectly capable of folding any
statement.

This can be the case when trying to fold other statements in the final
block of a path (for instance, in the forward threader as it tries to
fold candidate statements along a path).

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-path.cc (path_range_query::range_of_stmt): Remove
	GIMPLE_COND special casing.
	(path_range_query::range_defined_in_block): Use range_of_stmt
	instead of calling fold_range directly.
---
 gcc/gimple-range-path.cc | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index f4509b5a726..a4fa3b296ff 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -155,7 +155,6 @@ path_range_query::unreachable_path_p ()
 }
 
 // Return the range of STMT at the end of the path being analyzed.
-// Anything but the final conditional in a BB will return VARYING.
 
 bool
 path_range_query::range_of_stmt (irange &r, gimple *stmt, tree)
@@ -165,10 +164,9 @@ path_range_query::range_of_stmt (irange &r, gimple *stmt, tree)
   if (!irange::supports_type_p (type))
     return false;
 
-  if (gimple_code (stmt) == GIMPLE_COND && fold_range (r, stmt, this))
-    return true;
+  if (!fold_range (r, stmt, this))
+    r.set_varying (type);
 
-  r.set_varying (type);
   return true;
 }
 
@@ -237,7 +235,7 @@ path_range_query::range_defined_in_block (irange &r, tree name, basic_block bb)
 
   if (gimple_code (def_stmt) == GIMPLE_PHI)
     ssa_range_in_phi (r, as_a<gphi *> (def_stmt));
-  else if (!fold_range (r, def_stmt, this))
+  else if (!range_of_stmt (r, def_stmt, name))
     r.set_varying (TREE_TYPE (name));
 
   if (bb)
-- 
2.31.1


                 reply	other threads:[~2021-09-05 16:12 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=20210905161154.848779-1-aldyh@redhat.com \
    --to=aldyh@redhat.com \
    --cc=gcc-patches@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).