This is the mail archive of the gcc-patches@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]

Patch [tree-profiling]: propagate profiling in loop headers


The loop header copying code currently makes no attempt to preserve profiling info;
this patch fixes this.


We don't have enough information here, and you have to make some arbitrary choices.
For example, suppose you have a simple loop (edge counts in parentheses):


b1->b2 (1000)
b2->b3 (1000)
b3->b2 (1000)
b2->b4 (1000)

Copying the loop header b2 turns it into:

b1->b5 (1000)
b5->b4 (a)
b5->b3 (b)
b3->b2 (1000)
b2->b3 (a)
b2->b4 (b)

where a+b= 1000, but other than that we don't know what they are. You might guess
a=0, b=1000 (i.e. the loop body is executed once per entry) but there is no certainty about it.
The patch here takes a simplistic approach, dividing the counts of the copies of b2 in
proportion to the number of times the loop body is entered relative to the times the
loop is entered; thus you get a=b=500 in the above. It might be right, and I haven't
come up with a more complicated algorithm that matches my intuition in all cases.


Scaling is done in long long, which avoids a lot of "invalid profiling info" messages in
the dumps, but doesn't actually prevent an ICE as far as I know. I'm not sure what the
accuracy requirements are; this may not be necessary. scale_bbs_frequencies* is
moved to cfg.c per Jan's suggestion.


This is also broken in mainline, but I don't know of any actual bugs it fixes, so I doubt
it's appropriate for stage 3. I'm willing to learn otherwise though.


2004-12-02 Dale Johannesen <dalej@apple.com>

* basic-block.h (scale_bbs_frequencies_int): New declaration.
(scale_bbs_frequencies_gcov_type): New declaration.
* cfgloopmanip.c (scale_bbs_frequencies): Renamed to
scale_bbs_frequencies_int and moved to cfg.c.
(scale_loop_frequencies): Adjust call to it.
(duplicate_loop_to_header_edge): Adjust calls to it.
* cfg.c (RDIV): New (copied from cfgloopmanip.c).
(scale_bbs_frequencies_int): Moved from cfgloopmanip.c.
(scale_bbs_frequencies_gcov_type): New.
* tree-ssa-loop-ch.c (copy_loop_headers): Propagate profiling info.

Attachment: diffs1.txt
Description: Text document



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