Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: some quotes on switch and indirect branches

Author: Eugene Nalimov

Date: 17:00:24 11/21/05

Go up one level in this thread


On November 21, 2005 at 18:10:54, Dieter Buerssner wrote:

>[...]
>I guess, you mean this as a substitution for
>  if (depth < 0)
>    fm = fm1;
>  else
>    fm = fm2;
>
>I am surprised, that compilers are not able to do this themselves. I

I several times tried to modify Visual C to recognize additional cases where we
should emit conditional moves (last time was probably a year ago for
x64-targeting compiler). Every time I could demonstrate win on a small
artificial test case, but every large real world program either showed no gain
or slowed down.

I suspect there are several reasons for this:
* branch predictors are good, and majority of branches can be correctly
predicted
* CMOV is long instruction; short branch is shorter, so program with less CMOVs
fits better into cache
* there is no 8-bit form of CMOV
* CMOV has no "CMOV reg, immediate" form; if you need it you first have to load
immediate into register, this executing more instructions and increasing
register pressure -- serious problem on x86
* for invalid address "CMOV reg, memory" will give you access violation even if
condition is false.

Thanks,
Eugene



This page took 0.01 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.