optimization hints?
Alfred Perlstein
bright@rush.net
Wed Jun 30 15:43:00 GMT 1999
On Fri, 11 Jun 1999, Mike Stump wrote:
> > Date: Fri, 11 Jun 1999 04:06:15 -0500 (EST)
> > From: Alfred Perlstein <bright@rush.net>
>
> > 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.
>
> > if ((ret = poll(pfds, num_pfds, INFTIM)) == -1)
>
> > isn't it about time C developers had this kind of control over thier
> > code?
>
> Yes and no. gcc is better off if in this one case, gcc developers can
> tag `known' functions with expected results (or unexpected results as
> the case may be), and let the optimizer use this to rearrange code.
>
> For example, the simple rule that compares to -1 are usually false,
> even as a general optimization rule, would go a long way to doing the
> right thing in most C code I have seen.
>
> The results one gets from that one general rule I feel would be better
> than littering C code with attributes, pragma and the like.
>
> Also note that you can get most of the benefit by using
> -fbranch-probabilities, from the doc:
>
> @item -fbranch-probabilities
> After running a program compiled with @samp{-fprofile-arcs}
> (@pxref{Debugging Options,, Options for Debugging Your Program or
> @code{gcc}}), you can compile it a second time using
> @samp{-fbranch-probabilities}, to improve optimizations based on
> guessing the path a branch might take.
doh, I didn't realize that was available.
> if your port doesn't yet support this, maybe you want to contribute
> support for this?
I'm using i386-freebsd, it probably does, if not i'm pretty certain
I don't have the time or understanding of gcc to do this right now.
thanks for the advice.
-Alfred
More information about the Gcc
mailing list