SIMD support...

Walter Bright newshound2 at digitalmars.com
Fri Jan 6 16:06:21 PST 2012


On 1/6/2012 1:43 PM, Manu wrote:
> There is actually. To the compiler, the intrinsic is a normal function, with
> some hook in the code generator to produce the appropriate opcode when it's
> performing actual code generation.
> On most compilers, the inline asm on the other hand, is unknown to the compiler,
> the optimiser can't do much anymore, because it doesn't know what the inline asm
> has done, and the code generator just goes and pastes your asm code inline where
> you told it to. It doesn't know if you've written to aliased variables, called
> functions, etc.. it can no longer safely rearrange code around the inline asm
> block.. which means it's not free to pipeline the code efficiently.

And, in fact, the compiler should not try to optimize inline assembler. The IA 
is there so that the programmer can hand tweak things without the compiler 
defeating his attempts.

For example, suppose the compiler schedules instructions for processor X. The 
programmer writes inline asm to schedule for Y, because the compiler doesn't 
specifically support Y. The compiler goes ahead and reschedules it for X.

Arggh!

What dmd does do with the inline assembler is it keeps track of which registers 
are read/written, so that effective register allocation can be done for the 
non-asm code.


More information about the Digitalmars-d mailing list