Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Is this possible?

Author: Dann Corbit

Date: 16:39:30 09/26/02

Go up one level in this thread


On September 26, 2002 at 15:05:39, Dieter Buerssner wrote:

>On September 25, 2002 at 16:51:17, Dann Corbit wrote:
>
>>Here is what my compiler spit out (I could probably choose better flags too):
>
>When I look at the generated code, it seems, you couldn't choose better flags.
>To me, it looks essentially identical to the hand written assembly. The few
>differences (slightly other order of things, add eax, 1 instead of inc eax) I
>cannot judge. With my assembler knowledge mainly from 386 days and before, I
>would even trust the compiler more here, than myself writing this in assembler
>(I would come up with practically identical code as well). I could imagine, that
>the compiler knows something about pairing of the instructions, which I don't.
>He could also know better, about which labels should be aligned (perhaps
>dependent on specific processor switches). He can know easily, how many bytes
>each instruction needs. Perhaps using add eax, 1 makes a better alignment in the
>end, than the shorter inc eax.
>
>Gcc also produced practically the same code.

An aside:

This is faster for me:

static int      inbits[256] = {
    0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
};

int             Count(const BITBOARD B)
{
    return inbits[(unsigned char) B] +
    inbits[(unsigned char) (B >> 8)] +
    inbits[(unsigned char) (B >> 16)] +
    inbits[(unsigned char) (B >> 24)] +
    inbits[(unsigned char) (B >> 32)] +
    inbits[(unsigned char) (B >> 40)] +
    inbits[(unsigned char) (B >> 48)] +
    inbits[(unsigned char) (B >> 56)];
}




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.