This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Move rest_of_handle_ branch)prob before GCSE


> Hi,
> 
> Currently in toplev.c, the optimizations order is something like the
> following:
> 
> ...                             <= position A
> [rest_of_handle_gcse]
> [rest_of_handle_loop_optimize]
> [rest_of_handle_jump_bypass]
> [rest_of_handle_cfg]
> [rest_of_handle_branch_prob]    <= position B
> ....
> 
> Now, if I move branch_prob to position A before gcse , does this change
> affect the optimizations after branch_prob?
> >From the performance results, they are slight different.
> 
> The function "rest_of_handle_branch_prob" mainly contains two functions
> "branch_prob" and "estimate_probability".
> I think "branch_prob" has no effect for later optimizations (CFG is not
> changed, only instrumenation/collection profiling), but
> "estimate_probability" use the characteristic of CFG to determine the
> probability, which may generate different probabilities at position A/B,
> because the optimizations between A and B change the CFG. The
> probabilities provided by "estimate_probability" are used by other later
> optimizations such as "basic block reorder".
> 
> I'd like to know whether my explanation is correct or complete. Is there
> any other reason  the performance results are slightly different?

The problem is that loop optimizer rebuilds the CFG so the branch
predictions are lost.  You can't move it across pass not preserving the
profile so until we replace loop optimizer by new one, we have to keep
it this way.

Honza
> 
> 
> Thanks.
> 
> Qiong


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]