correct -fno-guess-branch-probabillity docs

James E Wilson wilson@specifixinc.com
Tue Nov 2 23:57:00 GMT 2004


A customer was confused by the wording of the
-fno-guess-branch-probability documentation.  The docs say gcc by
default uses a randomized model, and has non-deterministic behaviour. 
This is not true.  If it was, then the object file comparisons which are
part of the bootstrap process would not work.

Here is an attempt to rewrite the doc entry to be more accurate.

The option and the docs were added here:
    http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01275.html
    http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01380.html
And my original explanation of what was going on is here:
    http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01349.html

Comments anyone?  If I don't get any comments, I will go ahead and add
this in a few days.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

-------------- next part --------------
2004-11-02  James E Wilson  <wilson@specifixinc.com>

	* invoke.texi (-fno-guess-branch-probability): Rewrite.

Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.554
diff -p -p -r1.554 invoke.texi
*** invoke.texi	30 Oct 2004 20:22:54 -0000	1.554
--- invoke.texi	2 Nov 2004 23:18:35 -0000
*************** other, a few use both.
*** 4758,4776 ****
  
  @item -fno-guess-branch-probability
  @opindex fno-guess-branch-probability
! Do not guess branch probabilities using a randomized model.
  
! Sometimes GCC will opt to use a randomized model to guess branch
! probabilities, when none are available from either profiling feedback
! (@option{-fprofile-arcs}) or @samp{__builtin_expect}.  This means that
! different runs of the compiler on the same program may produce different
! object code.
! 
! In a hard real-time system, people don't want different runs of the
! compiler to produce code that has different behavior; minimizing
! non-determinism is of paramount import.  This switch allows users to
! reduce non-determinism, possibly at the expense of inferior
! optimization.
  
  The default is @option{-fguess-branch-probability} at levels
  @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
--- 4758,4774 ----
  
  @item -fno-guess-branch-probability
  @opindex fno-guess-branch-probability
! Do not guess branch probabilities using heuristics.
  
! GCC will use heuristics to guess branch probabilities if they are
! not provided by profiling feedback (@option{-fprofile-arcs}).  These
! heuristics are based on the control flow graph.  If some branch probabilities
! are specified by @samp{__builtin_expect}, then the heuristics will be
! used to guess branch probabilities for the rest of the control flow graph,
! taking the @samp{__builtin_expect} info into account.  The interactions
! between the heuristics and @samp{__builtin_expect} can be complex, and in
! some cases, it may be useful to disable the heuristics so that the effects
! of @samp{__builtin_expect} are easier to understand.
  
  The default is @option{-fguess-branch-probability} at levels
  @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.


More information about the Gcc-patches mailing list