public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jiu Fu Guo <guojiufu@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/guojiufu/heads/guojiufu-branch)] Fix bootstrap-O3 fail Date: Wed, 2 Jun 2021 04:14:25 +0000 (GMT) [thread overview] Message-ID: <20210602041425.ED4E13839C4A@sourceware.org> (raw) https://gcc.gnu.org/g:79af8adcfe8f4110505c86f6d0b13f38d744e101 commit 79af8adcfe8f4110505c86f6d0b13f38d744e101 Author: Jiufu Guo <guojiufu@linux.ibm.com> Date: Wed Jun 2 11:29:40 2021 +0800 Fix bootstrap-O3 fail Diff: --- gcc/tree-ssa-loop-split.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c index 0428b0abea6..926966a2bbc 100644 --- a/gcc/tree-ssa-loop-split.c +++ b/gcc/tree-ssa-loop-split.c @@ -1610,6 +1610,39 @@ get_ne_cond_branch (struct loop *loop) auto_vec<edge> edges = get_loop_exit_edges (loop); FOR_EACH_VEC_ELT (edges, i, e) { + basic_block bb = e->src; + + /* Check if exit at gcond. */ + gimple *last = last_stmt (bb); + if (!last || gimple_code (last) != GIMPLE_COND) + continue; + gcond *cond = as_a<gcond *> (last); + enum tree_code code = gimple_cond_code (cond); + if (!(code == NE_EXPR + || (code == EQ_EXPR && (e->flags & EDGE_TRUE_VALUE)))) + continue; + + /* Check if bound is invarant. */ + tree idx = gimple_cond_lhs (cond); + tree bnd = gimple_cond_rhs (cond); + if (expr_invariant_in_loop_p (loop, idx)) + std::swap (idx, bnd); + else if (!expr_invariant_in_loop_p (loop, bnd)) + continue; + + /* Only unsigned type conversion could cause wrap. */ + tree type = TREE_TYPE (idx); + if (!INTEGRAL_TYPE_P (type) || TREE_CODE (idx) != SSA_NAME + || !TYPE_UNSIGNED (type)) + continue; + + /* Avoid to split if bound is MAX/MIN val. */ + tree bound_type = TREE_TYPE (bnd); + if (TREE_CODE (bnd) == INTEGER_CST && INTEGRAL_TYPE_P (bound_type) + && (bnd == TYPE_MAX_VALUE (bound_type) + || bnd == TYPE_MIN_VALUE (bound_type))) + continue; + /* Check if there is possible wrap. */ class tree_niter_desc niter; if (!number_of_iterations_exit (loop, e, &niter, false, false)) @@ -1623,7 +1656,7 @@ get_ne_cond_branch (struct loop *loop) the split loops: just jump from the exit edge of one loop to the header of new loop. */ if (single_pred_p (loop->latch) - && single_pred_edge (loop->latch)->src == e->src + && single_pred_edge (loop->latch)->src == bb && empty_block_p (loop->latch)) return e; @@ -1631,10 +1664,10 @@ get_ne_cond_branch (struct loop *loop) only, it is simple to link the split loops: jump from the end of one loop header to the new loop header, and use unchanged PHI result of first loop as the entry PHI value of the second loop. */ - if (e->src == loop->header) + if (bb == loop->header) { /* Only one phi. */ - gphi_iterator psi = gsi_start_phis (e->src); + gphi_iterator psi = gsi_start_phis (bb); if (gsi_end_p (psi)) continue; gphi *phi = psi.phi (); @@ -1642,8 +1675,8 @@ get_ne_cond_branch (struct loop *loop) if (!gsi_end_p (psi)) continue; - /* Get the idx from last stmt (the gcond) of e->src. */ - gimple *gc = last_stmt (e->src); + /* Get the idx from last stmt (the gcond) of bb. */ + gimple *gc = last_stmt (bb); gcc_assert (gimple_code (gc) == GIMPLE_COND); tree idx = gimple_cond_lhs (gc); if (expr_invariant_in_loop_p (loop, idx)) @@ -1656,7 +1689,7 @@ get_ne_cond_branch (struct loop *loop) /* ++i or ++i */ gimple_stmt_iterator gsi - = gsi_start_nondebug_after_labels_bb (e->src); + = gsi_start_nondebug_after_labels_bb (bb); if (gsi_end_p (gsi)) continue;
reply other threads:[~2021-06-02 4:14 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210602041425.ED4E13839C4A@sourceware.org \ --to=guojiufu@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).