Your predict.c patch

Jan Hubicka jh@suse.cz
Fri Dec 14 13:16:00 GMT 2001


> Jan Hubicka <jh@suse.cz> writes:
> 
> >> Hi!
> >> 
> >> Your
> >> Thu Dec 13 12:31:07 CET 2001  Jan Hubicka  <jh@suse.cz>
> >> 
> >>         * predict.c (estimate_probability): Distribute the loop exit
> >>         probability according to number of exit edges.
> >> 
> >> patch broke a couple of testcases on ia32, particularly:
> >> FAIL: gcc.c-torture/compile/921202-1.c,  -Os
> >> FAIL: gcc.c-torture/compile/950613-1.c,  -O1
> >> FAIL: gcc.c-torture/compile/950613-1.c,  -Os
> >> 
> >> The problem is that if exits is 0, you divide by zero.
> >> Can you fix this?
> >> Thanks.
> > How did you configured gcc?  I am trying to reproduce it (i386/i686) but I don't
> > have the luck...
> 
> Same here:
> /private/cvs/gcc-mainline/configure --prefix=/opt/gcc/gcc-reference/ --enable-shared --enable-threads=posix --with-gnu-as --with-gnu-ld --disable-nls --with-system-zlib
> 
> On i686-linux-gnu (my dual athlon)
> 
> Check the gcc-testresults archive for failures from others,

Interestingly enoguht it reproduce for me now. I probably messed up something last time I tried.
It is due to latent bug in LOOP_EXIT heuristic fixed by following patch installed
as obvious:

Fri Dec 14 22:10:24 CET 2001  Jan Hubicka  <jh@suse.cz>
	* predict.c (estimate_probability): Fix LOOP_EXIT heuristic.
Index: predict.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/predict.c,v
retrieving revision 1.49
diff -c -3 -p -r1.49 predict.c
*** predict.c	2001/12/13 11:34:06	1.49
--- predict.c	2001/12/14 21:10:10
*************** estimate_probability (loops_info)
*** 358,364 ****
  	         successors.  */
  	      if (!header_found)
  		for (e = BASIC_BLOCK(j)->succ; e; e = e->succ_next)
! 		  if (e->dest->index <= 0
  		      || !TEST_BIT (loop->nodes, e->dest->index))
  		    predict_edge (e, PRED_LOOP_EXIT,
  				  (REG_BR_PROB_BASE
--- 358,364 ----
  	         successors.  */
  	      if (!header_found)
  		for (e = BASIC_BLOCK(j)->succ; e; e = e->succ_next)
! 		  if (e->dest->index < 0
  		      || !TEST_BIT (loop->nodes, e->dest->index))
  		    predict_edge (e, PRED_LOOP_EXIT,
  				  (REG_BR_PROB_BASE



More information about the Gcc-patches mailing list