www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Aligning data in memory / on the stack

reply Peter Alexander <peter.alexander.au gmail.com> writes:
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.
         ...
     }
}
Sep 16 2011
parent bearophile <bearophileHUGS lycos.com> writes:
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
Sep 16 2011