Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: when a & is faster than a && ?

Author: Gareth McCaughan

Date: 16:39:52 09/22/01

Go up one level in this thread


Eugene Nalimov wrote:

> I believe explanation is even simpler. Of course it all depend on
> the compiler,
> but probably for the code
>     (x == y) & (u == w)
> it generated something like
>     t1 = 1
>     if (x == y) goto L1
>     t1 = 0
> L1:
>     t2 = 1
>     if (u == w) goto L2
>     t2 = 0
> L2:
>     t3 = t1 & t2
>     ...
> So you have *both* mispredicted branches and memory accesses.

Someone should teach it to generate (if that's in a boolean
context)
    t3 = (x^y) | (u^w)
instead. Three instructions, no branches. (It will then need
to reverse the sense of the conditional, but that's not hard.)

--
g



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.