aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-manip.cc
diff options
context:
space:
mode:
authorHonza <jh@ryzen4.suse.cz>2023-07-28 19:39:19 +0200
committerHonza <jh@ryzen4.suse.cz>2023-07-28 19:39:19 +0200
commit88618fa0211d77d91b70f7af9b02e08a34b57912 (patch)
treecfd1053672c124cdf0613e618201b8f1a3f65280 /gcc/tree-ssa-loop-manip.cc
parentfdbb0863b6111ad3f45b79f47ebfe471555b2c4a (diff)
downloadgcc-88618fa0211d77d91b70f7af9b02e08a34b57912.zip
gcc-88618fa0211d77d91b70f7af9b02e08a34b57912.tar.gz
gcc-88618fa0211d77d91b70f7af9b02e08a34b57912.tar.bz2
Cleanup profile updating code in unrolling and splitting
I have noticed that for all these three cases I need same update of loop exit probability. While my earlier patch unified it for unrollers, this patch makes it more general and also simplifies tree-ssa-loop-split.cc. I also refactored the code, since with all the special cases for corrupted profile it gets relatively long. I now also handle multiple loop exits in RTL unroller. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: * cfgloopmanip.cc (loop_count_in): Break out from ... (loop_exit_for_scaling): Break out from ... (update_loop_exit_probability_scale_dom_bbs): Break out from ...; add more sanity check and debug info. (scale_loop_profile): ... here. (create_empty_loop_on_edge): Fix whitespac. * cfgloopmanip.h (update_loop_exit_probability_scale_dom_bbs): Declare. * loop-unroll.cc (unroll_loop_constant_iterations): Use update_loop_exit_probability_scale_dom_bbs. * tree-ssa-loop-manip.cc (update_exit_probability_after_unrolling): Remove. (tree_transform_and_unroll_loop): Use update_loop_exit_probability_scale_dom_bbs. * tree-ssa-loop-split.cc (split_loop): Use update_loop_exit_probability_scale_dom_bbs.
Diffstat (limited to 'gcc/tree-ssa-loop-manip.cc')
-rw-r--r--gcc/tree-ssa-loop-manip.cc30
1 files changed, 6 insertions, 24 deletions
diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc
index e58892e..e743691 100644
--- a/gcc/tree-ssa-loop-manip.cc
+++ b/gcc/tree-ssa-loop-manip.cc
@@ -1040,29 +1040,6 @@ determine_exit_conditions (class loop *loop, class tree_niter_desc *desc,
*exit_bound = bound;
}
-/* Updat NEW_EXIT probability after loop has been unrolled. */
-
-void
-update_exit_probability_after_unrolling (class loop *loop, edge new_exit)
-{
- /* gimple_duplicate_loop_body_to_header_edge depending on
- DLTHE_FLAG_UPDATE_FREQ either keeps original frequency of the loop header
- or scales it down accordingly.
- However exit edge probability is kept as original. Fix it if needed
- and compensate. */
- profile_probability new_prob
- = loop_preheader_edge
- (loop)->count ().probability_in (new_exit->src->count);
- if (!(new_prob == new_exit->probability))
- {
- profile_count old_count = new_exit->src->count - new_exit->count ();
- set_edge_probability_and_rescale_others (new_exit, new_prob);
- profile_count new_count = new_exit->src->count - new_exit->count ();
- scale_dominated_blocks_in_loop (loop, new_exit->src,
- new_count, old_count);
- }
-}
-
/* Unroll LOOP FACTOR times. LOOP is known to have a single exit edge
whose source block dominates the latch. DESC describes the number of
iterations of LOOP.
@@ -1289,7 +1266,12 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor,
update_ssa (TODO_update_ssa);
new_exit = single_dom_exit (loop);
- update_exit_probability_after_unrolling (loop, new_exit);
+ /* gimple_duplicate_loop_body_to_header_edge depending on
+ DLTHE_FLAG_UPDATE_FREQ either keeps original frequency of the loop header
+ or scales it down accordingly.
+ However exit edge probability is kept as original. Fix it if needed
+ and compensate. */
+ update_loop_exit_probability_scale_dom_bbs (loop, new_exit);
if (!single_loop_p)
{
/* Finally create the new counter for number of iterations and add