diff options
author | Jan Hubicka <jh@suse.cz> | 2023-07-06 18:51:02 +0200 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2023-07-06 18:51:02 +0200 |
commit | d4c2e34deef8cbd81ba2ef3389fdbaf95c70e225 (patch) | |
tree | 217bd3c15439fe3fff1a78d16dd31f8148404e8b /gcc/tree-vect-loop-manip.cc | |
parent | 224fd59b2dc8a5fa78a309a09863afe9b3cf2111 (diff) | |
download | gcc-d4c2e34deef8cbd81ba2ef3389fdbaf95c70e225.zip gcc-d4c2e34deef8cbd81ba2ef3389fdbaf95c70e225.tar.gz gcc-d4c2e34deef8cbd81ba2ef3389fdbaf95c70e225.tar.bz2 |
Improve scale_loop_profile
Original scale_loop_profile was implemented to only handle very simple loops
produced by vectorizer at that time (basically loops with only one exit and no
subloops). It also has not been updated to new profile-count API very carefully.
The function does two thigs
1) scales down the loop profile by a given probability.
This is useful, for example, to scale down profile after peeling when loop
body is executed less often than before
2) update profile to cap iteration count by ITERATION_BOUND parameter.
I changed ITERATION_BOUND to be actual bound on number of iterations as
used elsewhere (i.e. number of executions of latch edge) rather then
number of iterations + 1 as it was before.
To do 2) one needs to do the following
a) scale own loop profile so frquency o header is at most
the sum of in-edge counts * (iteration_bound + 1)
b) update loop exit probabilities so their count is the same
as before scaling.
c) reduce frequencies of basic blocks after loop exit
old code did b) by setting probability to 1 / iteration_bound which is
correctly only of the basic block containing exit executes precisely one per
iteration (it is not insie other conditional or inner loop). This is fixed
now by using set_edge_probability_and_rescale_others
aldo c) was implemented only for special case when the exit was just before
latch bacis block. I now use dominance info to get right some of addional
case.
I still did not try to do anything for multiple exit loops, though the
implementatoin could be generalized.
Bootstrapped/regtested x86_64-linux. Plan to cmmit it tonight if there
are no complains.
gcc/ChangeLog:
* cfgloopmanip.cc (scale_loop_profile): Rewrite exit edge
probability update to be safe on loops with subloops.
Make bound parameter to be iteration bound.
* tree-ssa-loop-ivcanon.cc (try_peel_loop): Update call
of scale_loop_profile.
* tree-vect-loop-manip.cc (vect_do_peeling): Likewise.
Diffstat (limited to 'gcc/tree-vect-loop-manip.cc')
-rw-r--r-- | gcc/tree-vect-loop-manip.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index d66d4a6..2361cb3 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -3191,7 +3191,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, if (prob_vector.initialized_p ()) { scale_bbs_frequencies (&bb_before_loop, 1, prob_vector); - scale_loop_profile (loop, prob_vector, 0); + scale_loop_profile (loop, prob_vector, -1); } } @@ -3236,7 +3236,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, slpeel_update_phi_nodes_for_guard1 (prolog, loop, guard_e, e); scale_bbs_frequencies (&bb_after_prolog, 1, prob_prolog); - scale_loop_profile (prolog, prob_prolog, bound_prolog); + scale_loop_profile (prolog, prob_prolog, bound_prolog - 1); } /* Update init address of DRs. */ @@ -3378,7 +3378,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1, scale_bbs_frequencies (&bb_before_epilog, 1, prob_epilog); } - scale_loop_profile (epilog, prob_epilog, 0); + scale_loop_profile (epilog, prob_epilog, -1); } else slpeel_update_phi_nodes_for_lcssa (epilog); |