This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Loop construction versus 0 frequency
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rakdver at atrey dot karlin dot mff dot cuni dot cz
- Date: Sun, 4 Feb 2007 21:12:42 +0100
- Subject: Loop construction versus 0 frequency
Hi,
while looking into some dumps I noticed that loop construction code makes interesting
decisions when frequencies are 0. This patch fix the problem.
The patch really just reindents and adds if (max_freq) guard for the
whole profile driven code block.
Bootstrapped/regtested i686-linux, will commit it shortly.
Honza
* cfgloop.c (canonicalize_loop_headers): When frequencies are zero,
do not attempt to use them.
Index: cfgloop.c
===================================================================
--- cfgloop.c (revision 121572)
+++ cfgloop.c (working copy)
@@ -402,30 +404,33 @@ canonicalize_loop_headers (void)
if (LATCH_EDGE (e) &&
EDGE_FREQUENCY (e) > max_freq)
max_freq = EDGE_FREQUENCY (e);
- FOR_EACH_EDGE (e, ei, header->preds)
- if (LATCH_EDGE (e) &&
- EDGE_FREQUENCY (e) >= max_freq / HEAVY_EDGE_RATIO)
- {
- if (heavy)
+ if (max_freq)
+ {
+ FOR_EACH_EDGE (e, ei, header->preds)
+ if (LATCH_EDGE (e) &&
+ EDGE_FREQUENCY (e) >= max_freq / HEAVY_EDGE_RATIO)
{
- is_heavy = 0;
- break;
+ if (heavy)
+ {
+ is_heavy = 0;
+ break;
+ }
+ else
+ heavy = e;
}
- else
- heavy = e;
- }
- if (is_heavy)
- {
- /* Split out the heavy edge, and create inner loop for it. */
- mfb_kj_edge = heavy;
- tmp_edge = make_forwarder_block (header, mfb_keep_just,
- update_latch_info);
- alloc_aux_for_block (tmp_edge->dest, sizeof (int));
- HEADER_BLOCK (tmp_edge->dest) = 1;
- alloc_aux_for_edge (tmp_edge, sizeof (int));
- LATCH_EDGE (tmp_edge) = 0;
- HEADER_BLOCK (header)--;
+ if (is_heavy)
+ {
+ /* Split out the heavy edge, and create inner loop for it. */
+ mfb_kj_edge = heavy;
+ tmp_edge = make_forwarder_block (header, mfb_keep_just,
+ update_latch_info);
+ alloc_aux_for_block (tmp_edge->dest, sizeof (int));
+ HEADER_BLOCK (tmp_edge->dest) = 1;
+ alloc_aux_for_edge (tmp_edge, sizeof (int));
+ LATCH_EDGE (tmp_edge) = 0;
+ HEADER_BLOCK (header)--;
+ }
}
if (HEADER_BLOCK (header) > 1)