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: Any way to do branch hints?



On May 25, 2004, at 12:27, Kean Johnston wrote:
Does gcc have any way in which I can portably introduce
branch hints, and do any of the machine descriptions
(of most personal interest is i386.md) use them? What
I'd liket o be able to do is something like:

In most of these cases, it's a good idea to mark the error routine as no-return if indeed it will raise an exception. This will cause GCC to automatically consider calls to it unlikely. The advantage is that you don't have to litter your source code at every call site.

For GNAT, this has been one of the main benefits of GCC 3,
since many people run code with all checks on, and now we
typically compile this into a conditional jump forward which
is statically predicted as not-taken on IA-32 systems.
Also, the likely path through the code is straight, which
allows for better I-cache usage.


int myfunc (void) { int x = foo();

 if (x == 0) __attribute__(branch-hint-not-taken)
   error();
 else {
   do_some_work();
 }
 return x;
}


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