> > > On 5/6/2021 8:36 PM, guojiufu via Gcc-patches wrote: > > Gentle ping. > > > > Original message: > > https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555871.html > I think you need a more aggressive ping :-) > > OK for the trunk. Sorry for the long delay. I kept hoping someone else > would step in and look at it. Sorry, the patch was on my todo list to think through for a while :( It seems to me that both old and new code needs bit more work. First the exit loop frequency is set to
prob = profile_probability::always ().apply_scale (1, new_est_niter + 1); which is only correct if the estimated number of iterations is accurate. If we do not have profile feedback and trip count is not known precisely in most cases it won't be. We estimate loops to iterate about 3 times and then niter_for_unrolled_loop will apply the capping to 5 iterations that is completely arbitrary. Forcing exit probability to precise may then disable futher loop optimizations since after the change we will think we know the loop iterates 5 times and thus it is not worthy for loop opt (which is quite oposite with the fact that we are just unrolling it thinking it is hot). Old code does 1) scale body down so only one iteration is done 2) set exit edge probability to be 1/(new_est_iter+1) precisely 3) scale up accoring to the 1/new_nonexit_prob which would be correct if the nonexit probability was updated to 1-exit_probability but that does not seem to happen. New code does 1) give up when there are multiple exits. I wonder how common this is - we do outer loop vectorizaiton 2) adjust loop body count according to the exit 3) updat profile of BB after the exit edge. Why do you need: + if (current_ir_type () != IR_GIMPLE) + update_br_prob_note (exit->src); It is tree_transform_and_unroll_loop, so I think we should always have IR_GIMPLE? Honza > > jeff