public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/loop-unswitching-switch)] WIP changes.
@ 2021-08-31 14:33 Martin Liska
0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-08-31 14:33 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9a2cb6a46aac3bf69e7158d876d1f6391c7d7229
commit 9a2cb6a46aac3bf69e7158d876d1f6391c7d7229
Author: Martin Liska <mliska@suse.cz>
Date: Tue Aug 31 11:50:33 2021 +0200
WIP changes.
Diff:
---
gcc/tree-ssa-loop-unswitch.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index c2100489b7f..c7cf0223501 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -391,14 +391,25 @@ tree_unswitch_single_loop (class loop *loop, int num)
tree lab = gimple_switch_label (gs, 1);
basic_block dest = label_to_block (cfun, CASE_LABEL (lab));
edge e = find_edge (gimple_bb (stmt), dest);
+ unsigned nlabels = gimple_switch_num_labels (gs);
+ for (unsigned i = 1; i < nlabels - 1; i++)
+ {
+ tree next_label = gimple_switch_label (gs, i + 1);
+ gimple_switch_set_label (gs, i, next_label);
+ basic_block next_dest
+ = label_to_block (cfun, CASE_LABEL (next_label));
+
+ /* Shared edge among multiple cases. */
+ if (e != NULL && e->dest == next_dest)
+ e = NULL;
+ }
// modifying the CFG here may play havoc on things like
// dominators and we really would like to prevent doing
// full update_ssa for each individual unswitching as well
- remove_edge (e);
- if (gimple_switch_num_labels (gs) > 1)
- gimple_switch_set_label (gs, 1,
- gimple_switch_label (gs, gimple_switch_num_labels (gs) - 1));
- gimple_switch_set_num_labels (gs, gimple_switch_num_labels (gs) - 1);
+ if (e != NULL)
+ remove_edge (e);
+
+ gimple_switch_set_num_labels (gs, nlabels - 1);
end_recording_case_labels ();
/* Update based on the adjusted switch. */
cond = tree_may_unswitch_on (bbs[i], loop);
@@ -406,7 +417,7 @@ tree_unswitch_single_loop (class loop *loop, int num)
changed = true;
}
// As said, it's a bit hackish to do it this way. */
- if (TREE_CODE (cond) == INTEGER_CST)
+ if (cond == NULL_TREE || TREE_CODE (cond) == INTEGER_CST)
;
/* Do not unswitch too much. */
else if (num > param_max_unswitch_level)
@@ -524,8 +535,10 @@ tree_unswitch_single_loop (class loop *loop, int num)
free_original_copy_tables ();
/* Invoke itself on modified loops. */
- tree_unswitch_single_loop (nloop, num + 1);
- tree_unswitch_single_loop (loop, num + 1);
+ if (nloop->aux != (void *)0xa5a5a5a5a5a5a5a5)
+ tree_unswitch_single_loop (nloop, num + 1);
+ if (loop->aux != (void *)0xa5a5a5a5a5a5a5a5)
+ tree_unswitch_single_loop (loop, num + 1);
free (bbs);
return true;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-31 14:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 14:33 [gcc(refs/users/marxin/heads/loop-unswitching-switch)] WIP changes Martin Liska
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).