Any way to do branch hints?
Geert Bosch
bosch@gnat.com
Tue May 25 18:31:00 GMT 2004
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;
}
More information about the Gcc
mailing list