This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


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

Re: [cygnus.project.sid] branch probability hinting


Tom Tromey writes:
 > >> Also please everyone note that the compiler already knows that
 > >> if (p == NULL)
 > >> is unlikely
 > 
 > Hans> Presumably it will take a hint that it's likely, e.g. when
 > Hans> scanning a sparse chained hash table?
 > 
 > I don't know.

I think it's worth doing the experiment.  I will if I have a moment to
spare.

 > Hans> How do you tell gcc that the branch probability is around 50-50
 > Hans> if it already believes otherwise?  (E.g. half the child pointers
 > Hans> in a binary tree are NULL.)

I don't think this makes any sense, given the way gcc does this.  It
can either prefer one or the other; AFAIK there is no way to be
ambivalent!

 > I don't think there is a way.  Maybe this should be reported as a gcc
 > bug.  Maybe you ought to be able to tell __builtin_expect the
 > probability that the branch is taken.

Cool.  It might be hard to make use of this.

Andrew.


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