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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -fno-guess-branch-probability switch...


> What exactly does the following imply?
> 
> ---------------
> -fno-guess-branch-probability
> Sometimes gcc will opt to guess branch probabilities when none are
> available from either profile directed feedback (`-fprofile-arcs')
> or `__builtin_expect'.  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.
> ---------------
> 
> It almost sounds to me like the branch-prediction is being done "randomly" in 
> some cases, so that the exact same code may be compiled differently given the 
> exact same compiler options, etc...
> 
> That is NOT correct, right??? In other words, the following statement would be 
> true:

It is not meant that the result is different over multiple compilations of the
same file, but after small modification of the file, the result may come out
very different, as the branch prediction heuristics may choose different path
to be hot one.

For instance changing test a<0 to a>0 will imply reordering of then and
else branches of if construct.

Honza
> 
> "Given the same source code and compiler switches, the gcc/g++ compiler will 
> produce the exact same binary code." 
> 
> Please advise.
> 
> Thanks!
> 
> Dave Fladebo
> dfladebo@starband.net


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