This is the mail archive of the
mailing list for the GCC project.
docs. on -fno-guess-branch-probability
- From: Dave Fladebo <dfladebo at starband dot net>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 7 May 2002 13:26:33 -0500
- Subject: docs. on -fno-guess-branch-probability
I recently came across a section of the docs. for gcc that was initially a bit
confusing to me and would like to propose a change.
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.
Depending on other optimization switch settings and source code, gcc may use
built-in branch probability optimization heuristics when information is not
available from either profile directed feedback (`-fprofile-arcs') or
(`__built-in_expect'). In a hard real-time system, it may be highly desirable
that source code with the same logical result [e.g.: if(x <= y) func1(); else
func2(); changed to if(x > y) func2(); else func1();] cause the generation of
executable code that performs the same, minimizing the possibility of
differences being introduce by branch prediction optimizations, even if this
may result in slower runtime performance. This switch instructs the compiler
to not use the built-in branch probability optimization heuristics.