diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-09-03 11:55:11 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-09-03 17:19:54 +0200 |
commit | 62099645c204f64cbf2546fc7c2cd0428c4990e0 (patch) | |
tree | eae3c17da66219926e069f0d452518ccd4acd41e /gcc/tree-ssa-threadedge.c | |
parent | 779275c0835b58325f806568836c8b5081d1f52f (diff) | |
download | gcc-62099645c204f64cbf2546fc7c2cd0428c4990e0.zip gcc-62099645c204f64cbf2546fc7c2cd0428c4990e0.tar.gz gcc-62099645c204f64cbf2546fc7c2cd0428c4990e0.tar.bz2 |
Abstract PHI and forwarder block checks in jump threader.
This patch abstracts out a couple common idioms in the forward
threader that I found useful while navigating the code base.
Tested on x86-64 Linux.
gcc/ChangeLog:
* tree-ssa-threadedge.c (has_phis_p): New.
(forwarder_block_p): New.
(potentially_threadable_block): Call forwarder_block_p.
(jump_threader::thread_around_empty_blocks): Call has_phis_p.
(jump_threader::thread_through_normal_block): Call
forwarder_block_p.
Diffstat (limited to 'gcc/tree-ssa-threadedge.c')
-rw-r--r-- | gcc/tree-ssa-threadedge.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index e57f6d3..3db54a1 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -95,6 +95,21 @@ jump_threader::thread_through_all_blocks (bool may_peel_loop_headers) return m_registry->thread_through_all_blocks (may_peel_loop_headers); } +static inline bool +has_phis_p (basic_block bb) +{ + return !gsi_end_p (gsi_start_phis (bb)); +} + +/* Return TRUE for a forwarder block which is defined as having PHIs + but no instructions. */ + +static bool +forwarder_block_p (basic_block bb) +{ + return gsi_end_p (gsi_start_nondebug_bb (bb)) && has_phis_p (bb); +} + /* Return TRUE if we may be able to thread an incoming edge into BB to an outgoing edge from BB. Return FALSE otherwise. */ @@ -107,9 +122,8 @@ potentially_threadable_block (basic_block bb) not optimized away because they forward from outside a loop to the loop header. We want to thread through them as we can sometimes thread to the loop exit, which is obviously profitable. - the interesting case here is when the block has PHIs. */ - if (gsi_end_p (gsi_start_nondebug_bb (bb)) - && !gsi_end_p (gsi_start_phis (bb))) + The interesting case here is when the block has PHIs. */ + if (forwarder_block_p (bb)) return true; /* If BB has a single successor or a single predecessor, then @@ -854,7 +868,7 @@ jump_threader::thread_around_empty_blocks (vec<jump_thread_edge *> *path, /* The key property of these blocks is that they need not be duplicated when threading. Thus they cannot have visible side effects such as PHI nodes. */ - if (!gsi_end_p (gsi_start_phis (bb))) + if (has_phis_p (bb)) return false; /* Skip over DEBUG statements at the start of the block. */ @@ -994,8 +1008,7 @@ jump_threader::thread_through_normal_block (vec<jump_thread_edge *> *path, { /* First case. The statement simply doesn't have any instructions, but does have PHIs. */ - if (gsi_end_p (gsi_start_nondebug_bb (e->dest)) - && !gsi_end_p (gsi_start_phis (e->dest))) + if (forwarder_block_p (e->dest)) return 0; /* Second case. */ |