On 2021/11/23 13:51, Xionghu Luo wrote:
> r12-4526 cancelled jump thread path rotates loop. It exposes a issue in
> profile-estimate when predict_extra_loop_exits, outer loop's exit edge
> is marked as inner loop's extra loop exit and set with incorrect
> prediction, then a hot inner loop will become cold loop finally through
> optimizations, this patch ignores the EDGE_DFS_BACK edge when searching
> extra exit edges to avoid unexpected predict_edge.
> 
> gcc/ChangeLog:
> 
>       PR middle-end/103270
>       * predict.c (predict_extra_loop_exits): Ignore EDGE_DFS_BACK edge.
> 
> gcc/ChangeLog:
> 
>       PR middle-end/103270
>       * predict.c (predict_extra_loop_exits): New.
> ---
>  gcc/predict.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/gcc/predict.c b/gcc/predict.c
> index 68b11135680..1ae8ccff72c 100644
> --- a/gcc/predict.c
> +++ b/gcc/predict.c
> @@ -1910,6 +1910,10 @@ predict_extra_loop_exits (edge exit_edge)
>       continue;
>        if ((check_value_one ^ integer_onep (val)) == 1)
>       continue;
> +      if (e->flags & EDGE_DFS_BACK)
> +     continue;

Sorry, made a mistake before send the patch, #if 0 #endif should be
removed...


>        if (EDGE_COUNT (e->src->succs) != 1)
>       {
>         predict_paths_leading_to_edge (e, PRED_LOOP_EXTRA_EXIT, NOT_TAKEN);
> 

-- 
Thanks,
Xionghu

Reply via email to