On Nov 1, 2005, at 12:10 AM, Rustam Muginov wrote:
Hello all.
Then performing opportunistic optimization, its not always possible
to rework data structures for proper alignment.
So most of the time I have to deal with unaligned data.
My question is - does anyone have the experience with the following
technique:
Allocate memory block (or create in on stack if maximum data size
is small enough and known at compile time). Make it 15 bytes larger
then maximum data size.
Create an "aligned" pointer to the data (like adding 15 to the
address and then clearing less significunt 4 bits).
Copy data into this aligned buffer.
Perform altivec operations.
Copy data back into the structure.
Use vec_perm instead; it is essentially executed for free. You
should use the padded-alignment technique when allocating your data
structure memory, but please note that malloc in Mac OS X always
returns 16-byte aligned blocks. If you're accessing a struct and the
alignment is unknown, you need lvsl/lvsr and perm, and you can always
use lve/sve if necessary.
--
Shaun Wexler
MacFOH http://www.macfoh.com