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/personal-branch)] Use number_of_iterations_exit as main check Date: Mon, 31 May 2021 05:56:38 +0000 (GMT) [thread overview] Message-ID: <20210531055638.EF3213858C27@sourceware.org> (raw) https://gcc.gnu.org/g:13490de7a8834e2e623f2bf3ef23e5a7bf94ffef commit 13490de7a8834e2e623f2bf3ef23e5a7bf94ffef Author: Jiufu Guo <guojiufu@linux.ibm.com> Date: Sat May 15 13:56:01 2021 +0800 Use number_of_iterations_exit as main check Diff: --- gcc/testsuite/g++.dg/vect/pr98064.cc | 4 ++- gcc/tree-ssa-loop-split.c | 51 ++++++++++++------------------------ 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/gcc/testsuite/g++.dg/vect/pr98064.cc b/gcc/testsuite/g++.dg/vect/pr98064.cc index 74043ce7725..dcb2985d05a 100644 --- a/gcc/testsuite/g++.dg/vect/pr98064.cc +++ b/gcc/testsuite/g++.dg/vect/pr98064.cc @@ -1,5 +1,7 @@ // { dg-do compile } -// { dg-additional-options "-O3" } +// { dg-additional-options "-O3 -Wno-stringop-overflow" } +/* There is warning message when "short g = var_8; g; g++" + is optimized/analyzed as string operation,e.g. memset. */ const long long &min(const long long &__a, long long &__b) { if (__b < __a) diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c index 6ae36635d6b..5c1742b5ff4 100644 --- a/gcc/tree-ssa-loop-split.c +++ b/gcc/tree-ssa-loop-split.c @@ -1609,51 +1609,29 @@ 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 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; - - /* If no overflow/wrap happen, no need to split. */ - if (nowrap_type_p (TREE_TYPE (idx))) - continue; + /* Check if there is possible wrap/overflow. */ class tree_niter_desc niter; - if (!number_of_iterations_exit (loop, e, &niter, false, false, NULL)) + if (!number_of_iterations_exit (loop, e, &niter, false, false)) continue; if (niter.control.no_overflow) return NULL; + if (niter.cmp != NE_EXPR) + continue; /* Check loop is simple to split. */ - gcc_assert (bb != loop->latch); - if (single_pred_p (loop->latch) - && single_pred_edge (loop->latch)->src == bb + && single_pred_edge (loop->latch)->src == e->src && (gsi_end_p (gsi_start_nondebug_bb (loop->latch)))) return e; - /* Cheap header. */ - if (bb == loop->header) + /* Simple header. */ + if (e->src == loop->header) { - if (get_virtual_phi (bb)) + if (get_virtual_phi (e->src)) continue; /* Only one phi. */ - gphi_iterator psi = gsi_start_phis (bb); + gphi_iterator psi = gsi_start_phis (e->src); if (gsi_end_p (psi)) continue; gsi_next (&psi); @@ -1661,18 +1639,23 @@ get_ne_cond_branch (struct loop *loop) continue; /* ++i or ++i */ - gimple_stmt_iterator gsi = gsi_start_bb (bb); + gimple_stmt_iterator gsi = gsi_start_bb (e->src); if (gsi_end_p (gsi)) continue; + gimple *gc = last_stmt (e->src); + tree idx = gimple_cond_lhs (gc); + if (expr_invariant_in_loop_p (loop, idx)) + idx = gimple_cond_rhs (gc); + gimple *s1 = gsi_stmt (gsi); - if (!(is_gimple_assign (s1) + if (!(is_gimple_assign (s1) && idx && (idx == gimple_assign_lhs (s1) || idx == gimple_assign_rhs1 (s1)))) continue; gsi_next (&gsi); - if (!gsi_end_p (gsi) && gsi_stmt (gsi) == cond) + if (!gsi_end_p (gsi) && gsi_stmt (gsi) == gc) return e; } }
next reply other threads:[~2021-05-31 5:56 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-31 5:56 Jiu Fu Guo [this message] -- strict thread matches above, loose matches on Subject: below -- 2021-05-20 6:28 Jiu Fu Guo
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=20210531055638.EF3213858C27@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).