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.