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]

Re: optimization hints?



  In message <Pine.BSF.3.96.990611035502.14320R-100000@cygnus.rush.net>you writ
e:
  > 
  > It has always seemed weird that C, the langue usually chosen because
  > it's closeness to the machine level wouldn't have a hint like 
  > system for doing branches.
  > 
  > Is there such a way to do this?
Not a good way.  Cygnus did something for a customer called __builtin_expect,
but it has some serious problems, so we never contributed the code.

For your particular case, a reasonable static branch predictor would catch
it since most would predict a return value of -1 has highly unlikely since
it's an extremely common error code.

Instead of building a lot of crud for programmer directed info, we're better
off putting in a real static branch predictor as well as beefing up the
code to provide runtime branch prediction to the compiler.

Once we hae that, then you can look at optimizations based on that information
like basic block reordering.

jeff


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