Fix for __builtin_expect on PowerPC

Michael Meissner meissner@cygnus.com
Sat Jun 16 14:49:00 GMT 2001


On Sat, Jun 16, 2001 at 11:01:27PM +0200, Jan Hubicka wrote:
> > > Can we handle conditional goto in same way, so we get predicted as unlikely?
> > 
> > I'm not sure what you mean by conditional goto, since do_jump handles
> > conditional jumps.  Do you have a fragment of code to explain what you want
> > predicted?
> One predictor from my TODO list :)
> Kernel folks often mention that sequences like
> if (something)
>    goto somewhere
> are usually used by programmer to handle error situation (in the kernel it is
> definitly common practice, I am not 100% sure that somewhere), but it can be
> nice to have such constructs marked by predictor so we can evaulate that.
> 
> Having this heuristic in will make kernel folks happier, as gcc will not
> reorder their curefully hacked code to have common path together in the
> source.

That's not that simple to do with the current framework, though I imagine when
the first jump pass converts:

	(set (pc) (if_then_else (test ...)
				(label_ref 1)
				(pc)))

	(set (pc) (label_ref 2))

	(code_label 1)

into:

	(set (pc) (if_then_else (not-test ...)
				(label_ref 2)
				(pc)))

it might be able to do it (I would probably check whether it is a user label as
well).

-- 
Michael Meissner, Red Hat, Inc.  (GCC group)
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482



More information about the Gcc-patches mailing list