www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.intrinsic

reply bearophile <bearophileHUGS lycos.com> writes:
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
Aug 13 2008
parent reply The Anh Tran <trtheanh gmail.com> writes:
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.
Aug 13 2008
parent reply The Anh Tran <trtheanh gmail.com> writes:
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.
Aug 13 2008
parent Walter Bright <newshound1 digitalmars.com> writes:
I added it to bugzilla.
Aug 14 2008