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)] using number_of_iterations_exit to check wrap/overflow Date: Thu, 20 May 2021 06:28:32 +0000 (GMT) [thread overview] Message-ID: <20210520062832.AFDF2394D818@sourceware.org> (raw) https://gcc.gnu.org/g:ed4bd03ea9e7555889d8af83c4bcdc3515dac2bb commit ed4bd03ea9e7555889d8af83c4bcdc3515dac2bb Author: Jiufu Guo <guojiufu@linux.ibm.com> Date: Fri May 14 23:33:57 2021 +0800 using number_of_iterations_exit to check wrap/overflow Diff: --- gcc/tree-ssa-loop-split.c | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c index 425593ca70f..6ae36635d6b 100644 --- a/gcc/tree-ssa-loop-split.c +++ b/gcc/tree-ssa-loop-split.c @@ -1629,43 +1629,15 @@ get_ne_cond_branch (struct loop *loop) else if (!expr_invariant_in_loop_p (loop, bnd)) continue; - /* By default, unsigned type conversion could cause overflow. */ - tree type = TREE_TYPE (idx); - if (!INTEGRAL_TYPE_P (type) || TREE_CODE (idx) != SSA_NAME - || !TYPE_UNSIGNED (type) - || TYPE_PRECISION (type) == TYPE_PRECISION (sizetype)) + /* If no overflow/wrap happen, no need to split. */ + if (nowrap_type_p (TREE_TYPE (idx))) 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; - - /* Extract conversion from idx. */ - if (TREE_CODE (idx) == SSA_NAME) - { - gimple *stmt = SSA_NAME_DEF_STMT (idx); - if (is_gimple_assign (stmt) - && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (stmt)) - && flow_bb_inside_loop_p (loop, gimple_bb (stmt))) - idx = gimple_assign_rhs1 (stmt); - } - - /* Check if idx is simple iv with possible overflow/wrap. */ - class loop *useloop = loop_containing_stmt (cond); - affine_iv iv; - if (!simple_iv (loop, useloop, idx, &iv, false)) + class tree_niter_desc niter; + if (!number_of_iterations_exit (loop, e, &niter, false, false, NULL)) continue; - if (iv.no_overflow) + if (niter.control.no_overflow) return NULL; - /* If base is know value (esplically 0/1), other optimizations may be - able to analyze "idx != bnd" as "idx < bnd" or "idx > bnd". */ - if (TREE_CODE (iv.base) == INTEGER_CST) - continue; - /* Check loop is simple to split. */ gcc_assert (bb != loop->latch);
next reply other threads:[~2021-05-20 6:28 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-20 6:28 Jiu Fu Guo [this message] 2021-05-31 5:56 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=20210520062832.AFDF2394D818@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).