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)] Fix switch bug! Date: Wed, 8 Dec 2021 11:14:50 +0000 (GMT) [thread overview] Message-ID: <20211208111450.984703858410@sourceware.org> (raw) https://gcc.gnu.org/g:a3ba6f3bb9dff3289345e7b84642c76350502bb9 commit a3ba6f3bb9dff3289345e7b84642c76350502bb9 Author: Martin Liska <mliska@suse.cz> Date: Wed Dec 8 12:14:27 2021 +0100 Fix switch bug! And add comments. Diff: --- gcc/tree-ssa-loop-unswitch.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c index 811f0cad343..d80b34db861 100644 --- a/gcc/tree-ssa-loop-unswitch.c +++ b/gcc/tree-ssa-loop-unswitch.c @@ -90,6 +90,8 @@ struct unswitch_predicate edge_index (edge_index_), handled (false) {} + /* Based on true_range, compute inverted range. */ + inline void init_false_edge (void) { @@ -100,6 +102,8 @@ struct unswitch_predicate false_range.invert (); } + /* Copy ranges for purpose of usage in predicate path. */ + inline void copy_merged_ranges () { @@ -107,11 +111,22 @@ struct unswitch_predicate merged_false_range = false_range; } + /* Unswitching expression. */ tree condition; + + /* LHS of the expression. */ tree lhs; + + /* Initial ranges (when the expression is true/false) for the expression. */ int_range_max true_range, false_range; + + /* Modified range that is part of a predicate path. */ int_range_max merged_true_range, merged_false_range; + + /* For switch predicates, index of the edge the predicate belongs to. */ int edge_index; + + /* True if the predicate was already used for unswitching. */ bool handled; }; @@ -451,6 +466,12 @@ find_unswitching_predicates_for_bb (basic_block bb, class loop *loop, unswitch_predicate *predicate = new unswitch_predicate (expr, idx, edge_index); ranger->gori().outgoing_edge_range_p (predicate->true_range, e, idx, *get_global_range_query ()); + /* Huge switches are not supported by Ranger. */ + if (predicate->true_range.undefined_p ()) + { + delete predicate; + return; + } predicate->init_false_edge (); candidates.safe_push (predicate);
next reply other threads:[~2021-12-08 11:14 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-12-08 11:14 Martin Liska [this message] 2021-12-08 18:26 Martin Liska 2021-12-09 12:49 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=20211208111450.984703858410@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).