diff options
author | Richard Biener <rguenther@suse.de> | 2022-08-24 10:08:17 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2022-08-24 11:47:05 +0200 |
commit | 9e50aebc813477655e0090b7de6578a7b11816ba (patch) | |
tree | 0f5632ab3c40114f6d7f2a014ab1680c0519bb87 | |
parent | 846e5c009e360f0c4fe58ff0d3aee03ebe3ca1a9 (diff) | |
download | gcc-9e50aebc813477655e0090b7de6578a7b11816ba.zip gcc-9e50aebc813477655e0090b7de6578a7b11816ba.tar.gz gcc-9e50aebc813477655e0090b7de6578a7b11816ba.tar.bz2 |
Some more predicate analysis TLC
This limits the simple control dep also to the cd_root plus avoids
filling the lazily computed PHI def predicate in the early out path
which would leave it not simplified and normalized if it were
re-used. It also avoids computing the use predicates when the
post-dominance early out doesn't need it. It also syncs
predicate::use_cannot_happen with init_from_phi_def, adding the
missing PHI edge to the computed chains (the simple control dep
code already adds it).
* gimple-predicate-analysis.cc (predicate::use_cannot_happen):
Do simple_control_dep_chain only up to cd_root, add the PHI
operand edge to the chains like init_from_phi_def does.
(predicate::is_use_guarded): Speedup early out, avoid half-way
initializing the PHI def predicate.
-rw-r--r-- | gcc/gimple-predicate-analysis.cc | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index ea81daa..f7170a8 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1322,10 +1322,15 @@ predicate::use_cannot_happen (gphi *phi, unsigned opnds) /* If compute_control_dep_chain bailed out due to limits build a partial sparse path using dominators. Collect only edges whose predicates are always true when reaching E. */ - simple_control_dep_chain (dep_chains[0], - ENTRY_BLOCK_PTR_FOR_FN (cfun), e); + simple_control_dep_chain (dep_chains[0], cd_root, e); num_chains++; } + /* Update the chains with the phi operand edge. */ + else if (EDGE_COUNT (e->src->succs) > 1) + { + for (unsigned j = 0; j < num_chains; j++) + dep_chains[j].safe_push (e); + } if (DEBUG_PREDICATE_ANALYZER && dump_file) { @@ -1916,24 +1921,14 @@ predicate::is_use_guarded (gimple *use_stmt, basic_block use_bb, /* The basic block where the PHI is defined. */ basic_block def_bb = gimple_bb (phi); + if (dominated_by_p (CDI_POST_DOMINATORS, def_bb, use_bb)) + /* The use is not guarded. */ + return false; + /* Try to build the predicate expression under which the PHI flows into its use. This will be empty if the PHI is defined and used in the same bb. */ predicate use_preds (def_bb, use_bb, m_eval); - - if (dominated_by_p (CDI_POST_DOMINATORS, def_bb, use_bb)) - { - if (is_empty ()) - { - /* Lazily initialize *THIS from the PHI and build its use - expression. */ - init_from_phi_def (phi); - } - - /* The use is not guarded. */ - return false; - } - if (use_preds.is_empty ()) return false; @@ -1955,9 +1950,7 @@ predicate::is_use_guarded (gimple *use_stmt, basic_block use_bb, { /* Lazily initialize *THIS from PHI. */ if (!init_from_phi_def (phi)) - { - return false; - } + return false; simplify (phi); normalize (phi); |