On 12/21/2011 8:49 AM, Ian Lance Taylor wrote:
I believe the probabilities will be combined in that case. The
weighting of __builtin_expect is such that it will most likely be the
predicted case, unless the profiling data says that the unexpected path
is always taken.
Thanks for the comment. The documentation for
-fno-guess-branch-probability says:
GCC will use heuristics to guess branch probabilities if they are
not provided by profiling feedback (-fprofile-arcs). These
heuristics are based on the control flow graph. If some branch
probabilities are specified by `__builtin_expect', then the
heuristics will be used to guess branch probabilities for the
rest of the control flow graph, taking the `__builtin_expect'
info into account. The interactions between the heuristics and
`__builtin_expect' can be complex, and in some cases, it may be
useful to disable the heuristics so that the effects of
`__builtin_expect' are easier to understand.
Is this is any way relevant? On the one hand, it's talking about
heuristics to be used in the absence of profiling feedback, and I'm
assuming we have profiling information. On the other hand, it's talking
about the interaction of probabilities and __builtin_expect, and those
probabilities presumably could come from PGO data.
Scott