Hi, > gcc/ChangeLog: > > PR tree-optimization/117790 > * tree-vect-loop.cc (scale_profile_for_vect_loop): Use > scale_loop_profile_hold_exit_counts instead of scale_loop_profile. Drop > the exit edge parameter, since the code now handles multiple exits. > Adjust the caller ... > (vect_transform_loop): ... here. > >gcc/testsuite/ChangeLog: > > PR tree-optimization/117790 > * gcc.dg/vect/vect-early-break-profile-2.c: New test. > > >- if (entry_count.nonzero_p ()) >- set_edge_probability_and_rescale_others >- (exit_e, >- entry_count.probability_in (loop->header->count / vf)); >- /* Avoid producing very large exit probability when we do not have >- sensible profile. */ >- else if (exit_e->probability < profile_probability::always () / (vf * 2))
This is handling relatively common case wehre we decide to vectorize loop with, say, factor of 32 and have no profile-feedback. In this case if the loop trip count is unknown at early loop, we will esitmate it to iterate few times (approx 3-5 as that is average iteration count of random loop based on some measurements). The fact that we want to vecotirze by factor 32 implies that vectorizer does not take this info seriously and its heuristics thinks better. In this case we do not wan to drop the loop to 0 iteraitons as that would result of poor code layout and regalloc. I don't think you kept this logic in the new code? Honza >- set_edge_probability_and_rescale_others (exit_e, exit_e->probability * >vf); >- loop->latch->count = single_pred_edge (loop->latch)->count (); >- >- scale_loop_profile (loop, profile_probability::always () / vf, >- get_likely_max_loop_iterations_int (loop)); >+ const auto likely_max_niters = get_likely_max_loop_iterations_int (loop); >+ scale_loop_profile_hold_exit_counts (loop, >+ profile_probability::always () / vf, >+ likely_max_niters);