unswitch most profitable condition first
authorRichard Biener <rguenther@suse.de>
Tue, 27 Sep 2022 08:16:52 +0000 (10:16 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 7 Nov 2022 08:59:26 +0000 (09:59 +0100)
commit7314b98b1bcd382c996a79bdcd0a1cb1e9231f55
tree043054286439775617248db7b0273c3741fba8ab
parenta8fb90eb3949bfb101bd6f50f24a029e10119591
unswitch most profitable condition first

When doing the loop unswitching re-org we promised to followup
with improvements on the cost modeling.  The following makes sure we
try to unswitch on the most profitable condition first.  As most profitable
we pick the condition leading to the edge with the highest profile count.

Note the profile is only applied when picking the first unswitching
opportunity since the profile counts are not updated with earlier
unswitchings in mind.  Further opportunities are picked in DFS order.

* tree-ssa-loop-unswitch.cc (unswitch_predicate::count): New.
(unswitch_predicate::unswitch_predicate): Initialize count.
(init_loop_unswitch_info): First collect candidates and
determine the outermost loop to unswitch.
(tree_ssa_unswitch_loops): First perform all guard hoisting,
then perform unswitching on innermost loop predicates.
(find_unswitching_predicates_for_bb): Keep track of the
most profitable predicate to unswitch on.
(tree_unswitch_single_loop): Unswitch given predicate if
not NULL.
gcc/tree-ssa-loop-unswitch.cc