This is the mail archive of the gcc-patches@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: [Patch, Fortran] Use __builtin_expect in libgfortran




Sent from my iPhone

On Aug 3, 2008, at 3:36, Tobias Burnus <tobias.burnus@physik.fu-berlin.de > wrote:

This patch replaces

 if (unlikely fulfilled condition)
   runtime_error (...);

by
 if (__builtin_expect (unlikely fulfilled condition, 0))
   runtime_error (...);

to speed up the library.

If rutime_error is marked as noreturn, gcc already does this internally. -- Pinski



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
<built-expect.diff>
<built-expect-gen.diff.gz>


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