Re: OT: alias options in gcc?
Re: OT: alias options in gcc?
- Subject: Re: OT: alias options in gcc?
- From: email@hidden
- Date: Tue, 26 Nov 2002 21:31:54 +0000
I use separate Obj-C objects for the vector and scalar versions of the
code. This is easy enough if you are doing specific mathematical
operations (such as an FFT). The objects have the same interface so an
id type can be used in class member declaration. The specific type
(altivec/scalar) is determined when the object is actually created.
This might be an option to avoid the problems mentioned with altivec
code and optimizations. BTW, I use O3 also.
-- John
If that function contains altivec code then there is probably some
prolog/epilog code for saving/restoring the altivec registers used by
the code and those instructions will get executed on the G3 and
kaboom! Since the compiler is free to do its register saving anywhere
it wants to, you can't assume that code like this will not blow up on
a G3.
void MyFunc( float * data, int numSamples, bool useAltivec )
{
if ( useAltivec )
{
vector float * fp = (vector float *) data;
... do some vector stuff
}
else
{
... do some scalar stuff ...
}
}
Even if the vector variables are all properly scoped the compiler will
do its save/restore stuff outside the block so you're not safe.
OR
inline void MyVectorFunc( vector float * data, int numSamples )
{
... do some vector stuff ...
}
void MyFunc( float * data, int numSamples, bool useAltivec )
{
if ( useAltivec == true )
MyVectorFunc( (vector float *) data, numSamples );
else
... do scalar stuff ...
}
If MyVectorFunc() gets inlined then you are cheesed.
Hope that helps,
stephen
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.