* [COMMITTED] Make back_threader_registry inherit from back_jt_path_registry.
@ 2021-10-28 12:32 Aldy Hernandez
2021-10-28 12:32 ` [COMMITTED] Improve backward threading with switches Aldy Hernandez
0 siblings, 1 reply; 2+ messages in thread
From: Aldy Hernandez @ 2021-10-28 12:32 UTC (permalink / raw)
To: GCC patches
When a class's only purpose is to expose the methods of its only
member, it's really a derived class ;-).
Tested on x86-64 Linux.
Committed as obvious.
gcc/ChangeLog:
* tree-ssa-threadbackward.c (class back_threader_registry):
Inherit from back_jt_path_registry.
(back_threader_registry::thread_through_all_blocks): Remove.
(back_threader_registry::register_path): Remove
m_lowlevel_registry prefix.
---
gcc/tree-ssa-threadbackward.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c
index d9ce056b06c..6c1b15904ce 100644
--- a/gcc/tree-ssa-threadbackward.c
+++ b/gcc/tree-ssa-threadbackward.c
@@ -49,13 +49,10 @@ along with GCC; see the file COPYING3. If not see
// registered with register_path(), thread_through_all_blocks() is called
// to modify the CFG.
-class back_threader_registry
+class back_threader_registry : public back_jt_path_registry
{
public:
bool register_path (const vec<basic_block> &, edge taken);
- bool thread_through_all_blocks (bool may_peel_loop_headers);
-private:
- back_jt_path_registry m_lowlevel_registry;
};
// Class to abstract the profitability code for the backwards threader.
@@ -541,12 +538,6 @@ back_threader::debug ()
dump (stderr);
}
-bool
-back_threader_registry::thread_through_all_blocks (bool may_peel_loop_headers)
-{
- return m_lowlevel_registry.thread_through_all_blocks (may_peel_loop_headers);
-}
-
/* Examine jump threading path PATH and return TRUE if it is profitable to
thread it, otherwise return FALSE.
@@ -873,8 +864,7 @@ bool
back_threader_registry::register_path (const vec<basic_block> &m_path,
edge taken_edge)
{
- vec<jump_thread_edge *> *jump_thread_path
- = m_lowlevel_registry.allocate_thread_path ();
+ vec<jump_thread_edge *> *jump_thread_path = allocate_thread_path ();
// The generic copier ignores the edge type. We can build the
// thread edges with any type.
@@ -885,12 +875,11 @@ back_threader_registry::register_path (const vec<basic_block> &m_path,
edge e = find_edge (bb1, bb2);
gcc_assert (e);
- m_lowlevel_registry.push_edge (jump_thread_path, e, EDGE_COPY_SRC_BLOCK);
+ push_edge (jump_thread_path, e, EDGE_COPY_SRC_BLOCK);
}
- m_lowlevel_registry.push_edge (jump_thread_path,
- taken_edge, EDGE_NO_COPY_SRC_BLOCK);
- m_lowlevel_registry.register_jump_thread (jump_thread_path);
+ push_edge (jump_thread_path, taken_edge, EDGE_NO_COPY_SRC_BLOCK);
+ register_jump_thread (jump_thread_path);
return true;
}
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [COMMITTED] Improve backward threading with switches.
2021-10-28 12:32 [COMMITTED] Make back_threader_registry inherit from back_jt_path_registry Aldy Hernandez
@ 2021-10-28 12:32 ` Aldy Hernandez
0 siblings, 0 replies; 2+ messages in thread
From: Aldy Hernandez @ 2021-10-28 12:32 UTC (permalink / raw)
To: GCC patches
We've been essentially using find_taken_edge_switch_expr() in the
backward threader, but this is suboptimal because said function only
works with singletons. VRP has a much smarter find_case_label_range
that works with ranges.
Tested on x86-64 Linux with:
a) Bootstrap & regtests.
b) Verifying we get more threads than before.
c) Asserting that the new code catches everything the old one
code caught (over a set of bootstrap .ii files).
Committed as obvious.
gcc/ChangeLog:
* tree-ssa-threadbackward.c
(back_threader::find_taken_edge_switch): Use find_case_label_range
instead of find_taken_edge.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/vrp106.c: Adjust for threading.
* gcc.dg/tree-ssa/vrp113.c: Same.
---
gcc/testsuite/gcc.dg/tree-ssa/vrp106.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/vrp113.c | 2 --
gcc/tree-ssa-threadbackward.c | 8 ++++----
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c
index f25ea9c3826..dc5021a57b5 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp106.c
@@ -1,6 +1,6 @@
/* PR tree-optimization/18046 */
-/* { dg-options "-O2 -fdump-tree-vrp-thread1-details" } */
-/* { dg-final { scan-tree-dump-times "Threaded jump" 1 "vrp-thread1" } } */
+/* { dg-options "-O2 -fdump-tree-ethread-details" } */
+/* { dg-final { scan-tree-dump-times "Registering jump thread" 1 "ethread" } } */
/* During VRP we expect to thread the true arm of the conditional through the switch
and to the BB that corresponds to the 7 ... 9 case label. */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c
index ab8d91e0f10..dfe4989d313 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp113.c
@@ -13,5 +13,3 @@ int f(int a) {
case 7: return 19;
}
}
-
-/* { dg-final { scan-tree-dump "return 3;" "vrp1" { xfail *-*-* } } } */
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c
index 6c1b15904ce..456effca5e1 100644
--- a/gcc/tree-ssa-threadbackward.c
+++ b/gcc/tree-ssa-threadbackward.c
@@ -195,11 +195,11 @@ back_threader::find_taken_edge_switch (const vec<basic_block> &path,
if (r.varying_p ())
return NULL;
- tree val;
- if (r.singleton_p (&val))
- return ::find_taken_edge (gimple_bb (sw), val);
+ tree label = find_case_label_range (sw, &r);
+ if (!label)
+ return NULL;
- return NULL;
+ return find_edge (gimple_bb (sw), label_to_block (cfun, CASE_LABEL (label)));
}
// Same as find_taken_edge, but for paths ending in a GIMPLE_COND.
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-28 12:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 12:32 [COMMITTED] Make back_threader_registry inherit from back_jt_path_registry Aldy Hernandez
2021-10-28 12:32 ` [COMMITTED] Improve backward threading with switches 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).