This is the mail archive of the
mailing list for the GCC project.
New attribute "infrequent"?
- To: gcc at gcc dot gnu dot org, pfk at fuchs dot offl dot uni-jena dot de, libc-alpha at sources dot redhat dot com, aj at suse dot de
- Subject: New attribute "infrequent"?
- From: Jan Hubicka <jh at suse dot cz>
- Date: Mon, 27 Aug 2001 17:47:51 +0200
several branch prediction papers consider classification of function calls to
discover calls to exceptional code (error handling, exit etc.) and predict them
as not happening. While this improves the call heuristics coverage
imporatatnly, I didn't considered it very important to implement, but after
generalizing it a bit, it kept in my mind for a few months now as potentially
We can add an attribute (probably called "infrequent") to the functions. Such
attribute exhibits a hint, that given function is definitly outside performance
cirtical code, so gcc can:
1) optimize it for size
2) use for branch prediction purposes
3) propagate the information to other functions allways calling infrequent
4) once procedure splitting is implemented (if at all), it can move whole
function to infrequently executed section.
I don't think the attribute is generally usefull in ordinary program, as most
of functions are "infrequent", but it may make sense for C library, that
contains also a lot of infrequent code itself (and it is dificult for compiler
to realize so) and additionally adding the flags to headers should improve
branch prediction considerably.
As the difference of code size between -Os to -O2 is over 20%, in case it is
realistic to assume that 50% of libc contains such a infreqnetly done thinks,
we can reduce it considerably.
Does this make sense? It would imply a lot of work on glibc side to tag all
An extension can be allowing infrequent on variables too (such as stderr) and
predicting any block containing reference to such variable as infrequently