This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Problem in propagating profiling information through loop unrolling
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Mostafa Hagog <MUSTAFA at il dot ibm dot com>
- Cc: gcc at gcc dot gnu dot org, Ayal Zaks <ZAKS at il dot ibm dot com>,Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Date: Mon, 19 Apr 2004 23:29:36 +0200
- Subject: Re: Problem in propagating profiling information through loop unrolling
- References: <OF71B7C4C4.9A451477-ONC2256E7B.0072427A-C2256E7B.0075404E@il.ibm.com>
>
> The following line from "scale_bbs_frequencies" of cfgloopmanip.c
> bbs[i]->count = (bbs[i]->count * num) / den;
> may cause a loop whose preheader has a count of 1 (and whose body has a
> very
> large count) to receive a zero preheader count after a precondition is
> inserted on the preheader edge. This phenomena was observed after noticing
> that the doloop rewrite (of Zedenek Dvorak) produced less branch-on-counts
> than the original one when feedback is turned on. The zero preheader count
> convinced the doloop optimization that it was not profitable to perform the
> doloop opt.
It seems to me that the doloop optimization shall not be at all
disabled by count/frequency of header being zero when the body has
nonzero count/frequency. Does the attached patch fix your problem too?
>
>
> IMHO, the result of the division should be rounded instead of truncated.
> When I used the below patch it fixed the problem - the unrolled loop was
> successfully "doloop'ed".
> I am not sure that this is the correct fix, please comment.
Rounding instead of truncating never hurts here too ;)
Index: cfgloopanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopanal.c,v
retrieving revision 1.2.4.10.2.3
diff -c -3 -p -r1.2.4.10.2.3 cfgloopanal.c
*** cfgloopanal.c 30 Mar 2004 23:18:42 -0000 1.2.4.10.2.3
--- cfgloopanal.c 19 Apr 2004 21:26:42 -0000
*************** expected_loop_iterations (const struct l
*** 431,437 ****
count_in += e->count;
if (count_in == 0)
! return 0;
expected = (count_latch + count_in - 1) / count_in;
--- 431,437 ----
count_in += e->count;
if (count_in == 0)
! return count_latch * 2;
expected = (count_latch + count_in - 1) / count_in;
*************** expected_loop_iterations (const struct l
*** 452,458 ****
freq_in += EDGE_FREQUENCY (e);
if (freq_in == 0)
! return 0;
return (freq_latch + freq_in - 1) / freq_in;
}
--- 452,458 ----
freq_in += EDGE_FREQUENCY (e);
if (freq_in == 0)
! return freq_latch * 2;
return (freq_latch + freq_in - 1) / freq_in;
}