View mode: basic / threaded / horizontal-split · Log in · Help
September 16, 2011
Aligning data in memory / on the stack
Can anyone help me with this?

http://stackoverflow.com/questions/7375165/aligning-stack-variables-in-d

---

Is there a way to align data on the stack? In particular, I want to 
create an 16-byte aligned array of floats to load into XMM registers 
using movaps, which is significantly faster than movups.

e.g.

void foo()
{
    float[4] v = [1.0f, 2.0f, 3.0f, 4.0f];
    asm
    {
        movaps XMM0, v; // v must be 16-byte aligned for this to work.
        ...
    }
}
September 16, 2011
Re: Aligning data in memory / on the stack
Peter Alexander:

> Is there a way to align data on the stack? In particular, I want to 
> create an 16-byte aligned array of floats to load into XMM registers 
> using movaps, which is significantly faster than movups.

Yours is a legitimate desire. I remember Don asking for this several times, and I remember Walter answering it's not an easy thing to do. I don't remember the current status of this. If others here later don't give you a good enough answer I suggest you to ask again in the main D newsgroup.

Bye,
bearophile
Top | Discussion index | About this forum | D home