Computer Chess Club Archives




Subject: Re: C and C++ --- NPS

Author: Matt Taylor

Date: 21:56:24 12/27/02

Go up one level in this thread

On December 27, 2002 at 17:47:19, Walter Faxon wrote:

>On December 26, 2002 at 22:48:35, Matt Taylor wrote:
><snip lotso neat stuff>
>>The "cmove" instruction is "conditional move if equal/zero." If the previous
>>comparison (val == some case) is true, it will replace the contents of result
>>with the second operand.
>>This strategy also works particularly well on IA-64 where the results of a
>>comparison go into any one of 64 special 1-bit registers. In the example you
>>gave, the particular symmetry would allow the processor to do the correct
>>computation quickly without branching at all.
>>In other cases where one is not so fortunate to have nice facilities, you can
>>play games with masks. I won't get into all the many tricks & techniques for
>>doing this because it would make this post even longer than it already is. In
>>the case of MMX/SSE vector extensions to IA-32, comparisons will give you a
>>resulting mask of -1 or 0 that you can manipulate.
><snip more great stuff -- this time for SSE>
>Other than my feeling a little retarded regarding cmove, etc., all I want to
>know now is:  do you know of any "mother lode(s)" for coding tricks?  (I already
>have a copy of the C-centric "Hacker's Delight".)
>Either way, thanks, Matt.  You've really opened my eyes.
>-- Walter

It is alright as I would not expect anyone to be familiar with all the tricks in
x86, and some people are still better at it than I am.

It is also noteworthy that one can sometimes avoid the virtual function call
with "virtual data" -- data that gets set based on the specific instantiation of
the class. It's all a matter of knowing how well the compiler can optimize
different constructs.

I wish I knew of a repository for tips & tricks. I glean a lot of my knowledge
of such topics from stuff I read on the web. I start out searching for something
specific, and 3 hours later I've read several completely unrelated articles.


This page took 0.02 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

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