Any usable SIMD implementation?

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 13 00:55:20 PDT 2016


On 13 April 2016 at 08:22, Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On 4/12/2016 4:29 PM, Marco Leise wrote:
>> In practice GDC will just replace the invokation with a single
>> 'mul' instruction while DMD will emit a call to this 18
>> instructions long function. Now you keep telling me extended
>> assembly is a step backwards. :)
>
>
> DMD version:
>
>   DblWord bigMul(ulong x, ulong y) {
>     naked asm {
>        mov RAX,RDI;
>        mul RSI;
>        ret;
>      }
>   }
>

Infact the "correct" version of "mul eax" is.

asm { "mul{l} {%%}eax" : "=a" var : "a" var; }

- Works with both dialects (Intel and ATT)
- Compiler knows the first register ("a") is read and written to, so
doesn't keep temporaries stored there.
- Compiler loads the variable "var" into EAX before the statement is executed.
- Compiler knows that the value of "var" in EAX after the statement is finished.

http://goo.gl/64SSD5

Just toggle on/off intel syntax to see the difference.  :-)

I can agree that the way that instruction (or insn) templates look are
pretty ugly.  But IMO, for the most part on x86 their ugliness is
attributed to having to support two types of assembler syntax at once.


More information about the Digitalmars-d mailing list