From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/106593 - fix ICE with backward threading
Date: Fri, 12 Aug 2022 12:59:36 +0200 (CEST) [thread overview]
Message-ID: <20220812105937.227C413305@imap2.suse-dmz.suse.de> (raw)
With the last re-org I failed to make sure to not add SSA names
nor supported by ranger into m_imports which then triggers an
ICE in range_on_path_entry because range_of_expr returns false. I've
noticed that range_on_path_entry does mightly complicated things
that don't make sense to me and the commentary might just be
out of date. For the sake of it I replaced it with range_on_entry
and statistics show we thread _more_ jumps with that, so better
not do magic there.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Will push if that succeeds.
PR tree-optimization/106593
* tree-ssa-threadbackward.cc (back_threader::find_paths):
If the imports from the conditional do not satisfy
gimple_range_ssa_p don't try to thread anything.
* gimple-range-path.cc (range_on_path_entry): Just
call range_on_entry.
---
gcc/gimple-range-path.cc | 33 +--------------------------------
gcc/tree-ssa-threadbackward.cc | 6 +++++-
2 files changed, 6 insertions(+), 33 deletions(-)
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index b6148eb5bd7..a7d277c31b8 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -153,38 +153,7 @@ path_range_query::range_on_path_entry (vrange &r, tree name)
{
gcc_checking_assert (defined_outside_path (name));
basic_block entry = entry_bb ();
-
- // Prefer to use range_of_expr if we have a statement to look at,
- // since it has better caching than range_on_edge.
- gimple *last = last_stmt (entry);
- if (last)
- {
- if (m_ranger->range_of_expr (r, name, last))
- return;
- gcc_unreachable ();
- }
-
- // If we have no statement, look at all the incoming ranges to the
- // block. This can happen when we're querying a block with only an
- // outgoing edge (no statement but the fall through edge), but for
- // which we can determine a range on entry to the block.
- Value_Range tmp (TREE_TYPE (name));
- bool changed = false;
- r.set_undefined ();
- for (unsigned i = 0; i < EDGE_COUNT (entry->preds); ++i)
- {
- edge e = EDGE_PRED (entry, i);
- if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun)
- && m_ranger->range_on_edge (tmp, e, name))
- {
- r.union_ (tmp);
- changed = true;
- }
- }
-
- // Make sure we don't return UNDEFINED by mistake.
- if (!changed)
- r.set_varying (TREE_TYPE (name));
+ m_ranger->range_on_entry (r, entry, name);
}
// Return the range of NAME at the end of the path being analyzed.
diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc
index 0a992213dad..669098e4ec3 100644
--- a/gcc/tree-ssa-threadbackward.cc
+++ b/gcc/tree-ssa-threadbackward.cc
@@ -525,7 +525,11 @@ back_threader::find_paths (basic_block bb, tree name)
bitmap_clear (m_imports);
ssa_op_iter iter;
FOR_EACH_SSA_TREE_OPERAND (name, stmt, iter, SSA_OP_USE)
- bitmap_set_bit (m_imports, SSA_NAME_VERSION (name));
+ {
+ if (!gimple_range_ssa_p (name))
+ return;
+ bitmap_set_bit (m_imports, SSA_NAME_VERSION (name));
+ }
// Interesting is the set of imports we still not have see
// the definition of. So while imports only grow, the
--
2.35.3
next reply other threads:[~2022-08-12 10:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-12 10:59 Richard Biener [this message]
2022-08-12 11:31 ` Aldy Hernandez
2022-08-12 11:35 ` Richard Biener
2022-08-12 15:29 ` Aldy Hernandez
2022-08-12 13:38 ` Andrew MacLeod
2022-08-12 14:07 ` Andrew MacLeod
2022-08-12 14:55 ` Aldy Hernandez
2022-08-15 12:33 ` Richard Biener
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=20220812105937.227C413305@imap2.suse-dmz.suse.de \
--to=rguenther@suse.de \
--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).