public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4700] Avoid threading circular paths.
@ 2021-10-26 6:21 Aldy Hernandez
0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-10-26 6:21 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e53fbb17839723ea1697fcbaf76b1c092675eaaf
commit r12-4700-ge53fbb17839723ea1697fcbaf76b1c092675eaaf
Author: Aldy Hernandez <aldyh@redhat.com>
Date: Wed Oct 20 18:52:45 2021 +0200
Avoid threading circular paths.
The backward threader keeps a hash of visited blocks to avoid crossing
the same block twice. Interestingly, we haven't been checking it for
the final block out of the path. This may be inherited from the old
code, as it was simple enough that it didn't matter. With the
upcoming changes enabling the fully resolving threader, it gets
tripped often enough to cause wrong code to be generated.
Tested on x86-64 Linux.
gcc/ChangeLog:
* tree-ssa-threadbackward.c (back_threader::maybe_register_path):
Avoid threading circular paths.
Diff:
---
gcc/tree-ssa-threadbackward.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c
index a6b9893abbd..d9ce056b06c 100644
--- a/gcc/tree-ssa-threadbackward.c
+++ b/gcc/tree-ssa-threadbackward.c
@@ -140,6 +140,10 @@ back_threader::maybe_register_path ()
if (taken_edge && taken_edge != UNREACHABLE_EDGE)
{
+ // Avoid circular paths.
+ if (m_visited_bbs.contains (taken_edge->dest))
+ return UNREACHABLE_EDGE;
+
bool irreducible = false;
bool profitable
= m_profit.profitable_path_p (m_path, m_name, taken_edge, &irreducible);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-26 6:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 6:21 [gcc r12-4700] Avoid threading circular paths Aldy Hernandez
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).