public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6061] Speedup DF dataflow solver Date: Wed, 15 Feb 2023 14:05:58 +0000 (GMT) [thread overview] Message-ID: <20230215140558.AE29C3858C66@sourceware.org> (raw) https://gcc.gnu.org/g:053d4dda0a205aba6af85fd9662118dd8109df9f commit r13-6061-g053d4dda0a205aba6af85fd9662118dd8109df9f Author: Richard Biener <rguenther@suse.de> Date: Tue Feb 14 14:46:47 2023 +0100 Speedup DF dataflow solver The following makes sure to process blocks that follow the current block in the iteration order in the same iteration and only postpone blocks that would be visited earlier to the next iteration. For the all.i testcase in PR26854 at -O2 this shaves off 50% of the time to solve the DF RD problem, other problems also improve but not as drastically. PR middle-end/26854 * df-core.cc (df_worklist_propagate_forward): Put later blocks on worklist and only earlier blocks on pending. (df_worklist_propagate_backward): Likewise. (df_worklist_dataflow_doublequeue): Change the iteration to process new blocks in the same iteration if that maintains the iteration order. Diff: --- gcc/df-core.cc | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/gcc/df-core.cc b/gcc/df-core.cc index e5ae9ab9348..38f69ac5743 100644 --- a/gcc/df-core.cc +++ b/gcc/df-core.cc @@ -874,7 +874,8 @@ make_pass_df_finish (gcc::context *ctxt) /* Helper function for df_worklist_dataflow. Propagate the dataflow forward. Given a BB_INDEX, do the dataflow propagation - and set bits on for successors in PENDING + and set bits on for successors in PENDING for earlier + and WORKLIST for later in bbindex_to_postorder if the out set of the dataflow has changed. AGE specify time when BB was visited last time. @@ -890,10 +891,11 @@ make_pass_df_finish (gcc::context *ctxt) static bool df_worklist_propagate_forward (struct dataflow *dataflow, - unsigned bb_index, - unsigned *bbindex_to_postorder, - bitmap pending, - sbitmap considered, + unsigned bb_index, + unsigned *bbindex_to_postorder, + bitmap worklist, + bitmap pending, + sbitmap considered, vec<int> &last_change_age, int age) { @@ -924,7 +926,13 @@ df_worklist_propagate_forward (struct dataflow *dataflow, unsigned ob_index = e->dest->index; if (bitmap_bit_p (considered, ob_index)) - bitmap_set_bit (pending, bbindex_to_postorder[ob_index]); + { + if (bbindex_to_postorder[bb_index] + < bbindex_to_postorder[ob_index]) + bitmap_set_bit (worklist, bbindex_to_postorder[ob_index]); + else + bitmap_set_bit (pending, bbindex_to_postorder[ob_index]); + } } return true; } @@ -937,10 +945,11 @@ df_worklist_propagate_forward (struct dataflow *dataflow, static bool df_worklist_propagate_backward (struct dataflow *dataflow, - unsigned bb_index, - unsigned *bbindex_to_postorder, - bitmap pending, - sbitmap considered, + unsigned bb_index, + unsigned *bbindex_to_postorder, + bitmap worklist, + bitmap pending, + sbitmap considered, vec<int> &last_change_age, int age) { @@ -971,7 +980,13 @@ df_worklist_propagate_backward (struct dataflow *dataflow, unsigned ob_index = e->src->index; if (bitmap_bit_p (considered, ob_index)) - bitmap_set_bit (pending, bbindex_to_postorder[ob_index]); + { + if (bbindex_to_postorder[bb_index] + < bbindex_to_postorder[ob_index]) + bitmap_set_bit (worklist, bbindex_to_postorder[ob_index]); + else + bitmap_set_bit (pending, bbindex_to_postorder[ob_index]); + } } return true; } @@ -1021,36 +1036,37 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow, and pending is for the next. */ while (!bitmap_empty_p (pending)) { - bitmap_iterator bi; - unsigned int index; - std::swap (pending, worklist); - EXECUTE_IF_SET_IN_BITMAP (worklist, 0, index, bi) + do { + unsigned index = bitmap_first_set_bit (worklist); + bitmap_clear_bit (worklist, index); + unsigned bb_index; dcount++; - bitmap_clear_bit (pending, index); bb_index = blocks_in_postorder[index]; prev_age = last_visit_age[index]; if (dir == DF_FORWARD) changed = df_worklist_propagate_forward (dataflow, bb_index, bbindex_to_postorder, - pending, considered, + worklist, pending, + considered, last_change_age, prev_age); else changed = df_worklist_propagate_backward (dataflow, bb_index, bbindex_to_postorder, - pending, considered, + worklist, pending, + considered, last_change_age, prev_age); last_visit_age[index] = ++age; if (changed) last_change_age[index] = age; } - bitmap_clear (worklist); + while (!bitmap_empty_p (worklist)); } BITMAP_FREE (worklist);
reply other threads:[~2023-02-15 14:05 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=20230215140558.AE29C3858C66@sourceware.org \ --to=rguenth@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).