This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Any way to do branch hints?
- From: Geert Bosch <bosch at gnat dot com>
- To: Kean Johnston <jkj at sco dot com>
- Cc: GCC development group <gcc at gcc dot gnu dot org>
- Date: Tue, 25 May 2004 14:31:10 -0400
- Subject: Re: Any way to do branch hints?
- References: <40B373DB.6000609@sco.com>
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;
}