From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 37E153858C54; Wed, 24 Aug 2022 09:47:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37E153858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661334445; bh=Nm+mwAGpnrJmC8pa6vHGYvTtPQUGvNGJO7xw/Ih2GZA=; h=From:To:Subject:Date:From; b=aRp/Cef9XL97r2GVSGexJ7++UcpB+kMGauXPvZf967F5TrO74ToUD2vcqB/U33T4k VyfIyh5CB8bhWp6I6oerRBn6rW4zXS1oG/T1Fmle5qUqGDQBoZZOoBtPU9cCy0CW3f HaXRjZqLVdsNy3HJWgpecSVgKUZvamd5LDWbs7l8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2169] Some more predicate analysis TLC X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 846e5c009e360f0c4fe58ff0d3aee03ebe3ca1a9 X-Git-Newrev: 9e50aebc813477655e0090b7de6578a7b11816ba Message-Id: <20220824094725.37E153858C54@sourceware.org> Date: Wed, 24 Aug 2022 09:47:25 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9e50aebc813477655e0090b7de6578a7b11816ba commit r13-2169-g9e50aebc813477655e0090b7de6578a7b11816ba Author: Richard Biener Date: Wed Aug 24 10:08:17 2022 +0200 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. Diff: --- gcc/gimple-predicate-analysis.cc | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index ea81daacd4f..f7170a8d068 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);