aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-08-26 10:01:44 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-08-26 14:42:16 +0200
commit0ceeb9926d69dbb382622a8eae9eef7ed8ac3e97 (patch)
tree88540167fede144dc95b00423ef1cf2ec2259d12 /gcc
parent03b802e14f497e393e6437b7df5be1c690ddf1df (diff)
downloadgcc-0ceeb9926d69dbb382622a8eae9eef7ed8ac3e97.zip
gcc-0ceeb9926d69dbb382622a8eae9eef7ed8ac3e97.tar.gz
gcc-0ceeb9926d69dbb382622a8eae9eef7ed8ac3e97.tar.bz2
tree-optimization/116460 - improve forwprop compile-time
The following improves forwprop block reachability which I noticed when debugging PR116460 and what is also noted in the comment. It avoids processing blocks in natural loops determined unreachable, thereby making the issue in PR116460 latent. PR tree-optimization/116460 * tree-ssa-forwprop.cc (pass_forwprop::execute): Do not process blocks in unreachable natural loops.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-ssa-forwprop.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index e7342b4..2964420 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -3498,6 +3498,8 @@ pass_forwprop::execute (function *fun)
cfg_changed = false;
+ calculate_dominance_info (CDI_DOMINATORS);
+
/* Combine stmts with the stmts defining their operands. Do that
in an order that guarantees visiting SSA defs before SSA uses. */
lattice.create (num_ssa_names);
@@ -3537,12 +3539,11 @@ pass_forwprop::execute (function *fun)
FOR_EACH_EDGE (e, ei, bb->preds)
{
if ((e->flags & EDGE_EXECUTABLE)
- /* With dominators we could improve backedge handling
- when e->src is dominated by bb. But for irreducible
- regions we have to take all backedges conservatively.
- We can handle single-block cycles as we know the
- dominator relationship here. */
- || bb_to_rpo[e->src->index] > i)
+ /* We can handle backedges in natural loops correctly but
+ for irreducible regions we have to take all backedges
+ conservatively when we did not visit the source yet. */
+ || (bb_to_rpo[e->src->index] > i
+ && !dominated_by_p (CDI_DOMINATORS, e->src, e->dest)))
{
any = true;
break;