This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Altivec strangeness?

On Saturday, February 23, 2002, at 02:55  AM, Daniel Egger wrote:

> Hija,
> I'm fooling around with altivec and tried to convert my sources, thereby
> I discovered the following strangeness:
> #include <altivec.h>
> static const vector signed short test = {1, 2, 3, 4, 5, 6, 7, 8};

the above should be:

blah vector signed short test = (vector signed short){1,2,3,etc};

the altivec specs mention that you need a cast.  this is a context
sensitivity issue.  gcc can't know what {1,2,3,etc} is.  perhaps
the compiler you are using now uses context magic to figure out
what type the initializer is... gcc won't do that.

> And further: How do I initialize a vector with the same value
> to all elements?
> static const vector signed short foo = {1};

1,1,1,1,1,1,1,1 ;-)

seriously, the (1) nonsense will work with jason merrill's patches
but you'll have to apply those on your own.  but please don't.
the hope is to wean people off of the parentheses nonsense-- alongside
that, wean them off of the {1} stuff.  that just goes against
C syntax.

> gives me {1, 0, 0, 0, 0, 0, 0, 0, 0} as result which is loaded
> from memory whilst a vector splat might be more efficient here.

warning will robbinson!  the vector initializer code is not, ahem,
efficient.  it will need to be rewritted with vector constants to
yield better code, perhaps for 3.2.  but imo, that's not a big issue
because you never initialize a vector inside a loop.

Aldy Hernandez                                E-mail:
Professional Gypsy Lost in Australia
Red Hat, Inc.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]