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]

Compilation-time suggestion


I have a proposal/suggestion for perhaps improving GCC compilation
time: Perhaps we could make more use of __builtin_expect inside the
compiler itself.

I'm not sure how much it would save us, but Jan's experiments
with profiled bootstraps seemed to be encouraging, if memory
serves.  Certainly, SPEC results are much more competative with
profiling enabled.

If our profiling tools could be used to identify a small number
of critial conditionals in the source code level, they could be
annotated with __builtin_expect.  Hopefully, this might be able
to gain us much of the benefit of profile-feedback statically,
assuming that its a few hotspots are responsible for a significant
fraction of the gain.

The usual use of macros in system.h can be used to allow the source
code to bootstrap on non-GCC compilers.

In addition to the tools locating critical conditionals at the
source code level, we'd also need the ability to identify those
__builtin_expect annotations that were incorrect or no longer
critical, to prevent too much obfuscation of the source code.
But certainly, machine generated functions such as the garbage
collector's traversals and insn-recog could be made expectation
aware.


Clearly, there are issues with training sets, and branch probabilities
that differ between one platform and another, but the hypothesis is
that a handfull, perhaps 100, __builtin_expect annotations might give
us a few percentage points, but maybe more.


Are the benefits of user-annotated branch predictions significant
enough to make them worth going after?  Do any of the distributions
come with a profile-optimized GCC?


Just throwing out a brain-storm to see if anyone has a better handle
on the potential benefits vs. increased maintenance overheads.

Roger
--


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