Thread overview
std.intrinsic
Aug 13, 2008
bearophile
Re: std.intrinsic - SSE data type
Aug 14, 2008
The Anh Tran
Aug 14, 2008
The Anh Tran
Aug 15, 2008
Walter Bright
August 13, 2008
The functions of the std.intrinsic module (that I presume are often asm instructions) look nice, but time ago I have seen that normal D code is fasten than some of them:

You can see it from this code that use bt and btr:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievebits&lang=dlang&id=2

http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievebits&lang=dlang&id=1

The code that uses IsSet and Clear (functions originally coming from Pascal code) is faster:

bool IsSet(uint i) {
    int offset = i / bpc;
    uint mask = 1 << (i % bpc);
    return (flags[offset] & mask) <> 0;
}

void Clear(uint i) {
    int offset = i / bpc;
    uint mask = 1 << (i % bpc);
    if((flags[offset] & mask) <> 0)
        flags[offset] = flags[offset] ^ mask;
}

So I can suggest to replace those functions of Phobos with functions in normal D code (such things are very useful to manage array of bits, that I use).

Bye,
bearophile
August 14, 2008
This should be posted on D.learn, but i think it also has some relevant to intrinsic here :|

Currently D doesn't provide vector data type __attribute__((vector(xyz)) and intrinsics that operate on those vector types.

I'm forced to go back to asm{}.
And for asm, there is a bug in dmd.1.030

movmskpd	ECX,	XMM7;
is compiled to:
movmskpd	EDI,	XMM7;


Anyone else can confirm the same issue?
Thanks.
August 14, 2008
Sorry, typo :(
movmskpd	EAX,	XMM7;	
->
movmskpd	EDI,	XMM7;	

The Anh Tran wrote:
> movmskpd    ECX,    XMM7;
> is compiled to:
> movmskpd    EDI,    XMM7;
> 
> 
> Anyone else can confirm the same issue?
> Thanks.
August 15, 2008
I added it to bugzilla.