[Patch, Fortran] Use __builtin_expect in libgfortran
Tobias Burnus
tobias.burnus@physik.fu-berlin.de
Sun Aug 3 10:37:00 GMT 2008
This patch replaces
if (unlikely fulfilled condition)
runtime_error (...);
by
if (__builtin_expect (unlikely fulfilled condition, 0))
runtime_error (...);
to speed up the library.
See: http://www.imodulo.com/gnu/gcc/Other-Builtins.html
"The use of __builtin_expect has now two uses:
- on platforms where conditional jump instructions have prediction bits
this information can be used to set them
- on all architectures it should now be possible to use
-freorder-blocks
to use the information to put the basic blocks in an order which
guarantees an optimal straight pass through the code for the
normal case."
(quote from http://sources.redhat.com/ml/libc-hacker/2000-04/msg00129.html
-freorder-blocks is enabled with -O2)
I hope that I have not missed any place or wrongly marked something as
likely/unlikely which is not.
Build and check-gfortraned on x86-64-linux
OK for the trunk?
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: built-expect.diff
Type: text/x-diff
Size: 82598 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080803/d9af0ae4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: built-expect-gen.diff.gz
Type: application/octet-stream
Size: 38357 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080803/d9af0ae4/attachment.obj>
More information about the Fortran
mailing list