Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: some quotes on switch and indirect branches

Author: Gerd Isenberg

Date: 15:06:22 11/18/05

Go up one level in this thread



>The compiler is free to do the replacement for you.

Agreed, compiler should sniff the control structures also with PGO and should
produce the "optimal" code for _that_ processor - regardless if you have switch,
if-elses or explicit indirect call via arrays of (member) function pointers (or
even virtual function calls), considering the number of cases.

Unfortunately compiler are not that perfect yet, with amd64 in mind,
likely the "dominating" architecture for some years.

In time critical code you may recognize some differences after playing with
control structures, or if you have really random pattern to replace branches by
register calculation.

I like to understand how the indirect branch exactly works on amd64. Is it a
kind of stall - until the correct address becomes available from the retired
branch instruction, or is it like P4, speculative taking the branch target
occured before?

Actually i use some explicit indirect call via arrays of member function
pointers. Move kind specific stuff, direction specific stuff - in my "future"
aproach i like to avoid that by "design".

>
>Never micro-optimize by changing the construct from the most sensible one to one
>less sensible but which you might think to be faster.[*]
>
>IMO-YMMV
>
>[*] Unless you have benchmarked the code, it is a hot-spot, it causes the code
>to fall below specification, and the modified code fixes the problem.

Yes, qsearch, see, eval etc. are suited for optimizations and data alignment and
cache line issues and considerations - if you already have a perfect branching
factor...

Gerd



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.