public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Simplify a bit. Date: Tue, 7 Dec 2021 16:49:36 +0000 (GMT) [thread overview] Message-ID: <20211207164936.1E39F385800C@sourceware.org> (raw) https://gcc.gnu.org/g:c3bb95e454e057db7a0dbdad21b19058a8178b88 commit c3bb95e454e057db7a0dbdad21b19058a8178b88 Author: Martin Liska <mliska@suse.cz> Date: Tue Nov 30 17:30:16 2021 +0100 Simplify a bit. Diff: --- gcc/tree-ssa-loop-unswitch.c | 46 ++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 4bb108adc7c..7b5bd8afec7 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -41,8 +41,6 @@ along with GCC; see the file COPYING3. If not see #include "gimple-range.h" #include "dbgcnt.h" -#include <utility> - /* This file implements the loop unswitching, i.e. transformation of loops like while (A) @@ -474,32 +472,30 @@ evaluate_insns (class loop *loop, basic_block *bbs, int flags = 0; basic_block bb = worklist.pop (); - if (EDGE_COUNT (bb->succs) == 2) + gimple *last = last_stmt (bb); + gcond *cond = last != NULL ? dyn_cast<gcond *> (last) : NULL; + if (cond != NULL) { - gcond *cond = dyn_cast<gcond *> (last_stmt (bb)); - if (cond != NULL) + if (gimple_cond_true_p (cond)) + flags = EDGE_FALSE_VALUE; + else if (gimple_cond_false_p (cond)) + flags = EDGE_TRUE_VALUE; + else { - if (gimple_cond_true_p (cond)) - flags = EDGE_FALSE_VALUE; - else if (gimple_cond_false_p (cond)) - flags = EDGE_TRUE_VALUE; - else + // FIXME: works only for gconds + unswitch_predicate *predicate = NULL; + if (!get_predicates_for_bb (bb).is_empty ()) + predicate = get_predicates_for_bb (bb)[0]; + + if (predicate != NULL) { - // FIXME: works only for gconds - unswitch_predicate *predicate = NULL; - if (!get_predicates_for_bb (bb).is_empty ()) - predicate = get_predicates_for_bb (bb)[0]; - - if (predicate != NULL) - { - tree folded - = evaluate_control_stmt_using_entry_checks (cond, - predicate_path); - if (folded == boolean_true_node) - flags = EDGE_FALSE_VALUE; - else if (folded == boolean_false_node) - flags = EDGE_TRUE_VALUE; - } + tree folded + = evaluate_control_stmt_using_entry_checks (cond, + predicate_path); + if (folded == boolean_true_node) + flags = EDGE_FALSE_VALUE; + else if (folded == boolean_false_node) + flags = EDGE_TRUE_VALUE; } } }
next reply other threads:[~2021-12-07 16:49 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-07 16:49 Martin Liska [this message] 2021-12-08 10:17 Martin Liska 2021-12-08 18:25 Martin Liska 2021-12-09 12:47 Martin Liska
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=20211207164936.1E39F385800C@sourceware.org \ --to=marxin@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).