optimizing calling conventions for function returns
Geert Bosch
bosch@adacore.com
Thu May 25 18:56:00 GMT 2006
On May 25, 2006, at 13:21, Jon Smirl wrote:
> jmp *4($esp)
>
> This is slightly faster than addl, ret.
The point is that this is only executed in the error case.
> But my micro scale benchmarks are extremely influenced by changes in
> branch prediction. I still wonder how this would perform in large
> programs.
The jmp *4($esp) doesn't confuse the branch predictors. Basically
the assumption is that call and ret instructions match up. Your
addl, ret messes up that assumption, which means the return predictions
will all be wrong.
Maybe the future link-time optimizations might be able to handle
this kind of error-exit code automatically, but for now I think
your best bet is handling this explicitly or just not worry about
the minor inefficiency.
-Geert
More information about the Gcc
mailing list