SIMD support...

Walter Bright newshound2 at digitalmars.com
Fri Jan 6 10:53:34 PST 2012


On 1/6/2012 6:05 AM, Manu wrote:
> On 6 January 2012 08:22, Walter Bright <newshound2 at digitalmars.com
> <mailto:newshound2 at digitalmars.com>> wrote:
>
>     On 1/5/2012 7:42 PM, Manu wrote:
>
>         Perhaps I misunderstand, I can't see the problem?
>         In the function preamble, you just align it... something like:
>            mov reg, esp ; take a backup of the stack pointer
>            and esp, -16 ; align it
>
>         ... function
>
>            mov esp, reg ; restore the stack pointer
>            ret 0
>
>
>     And now you cannot access the function's parameters anymore, because the
>     stack offset for them is now variable rather than fixed.
>
>
> Hehe, true, but not insurmountable. Scheduling of parameter pops before you
> perform the alignment may solve that straight up, or else don't align esp its
> self; store the vector to the stack through some other aligned reg copied from
> esp...
>
> I just wrote some test functions using __m128 in VisualC, it seems to do
> something in between the simplicity of my initial suggestion, and my refined
> ideas one above :)
> If you have VisualC, check out what it does, it's very simple, looks pretty
> good, and I'm sure it's optimal (MS have enough R&D money to assure this)
>
> I can paste some disassemblies if you don't have VC...

I don't have VC. I had thought of using an extra level of indirection for all 
the aligned stuff, essentially rewrite:

     v128 v;
     v = x;

with:

     v128 v; // goes in aligned stack
     v128 *pv = &v;  // pv is in regular stack
     *pv = x;

but there are still complexities with it, like spilling aligned temps to the stack.


More information about the Digitalmars-d mailing list