This is the mail archive of the
mailing list for the GCC project.
Re: conversions between vectors
- From: Daniel Berlin <dan at cgsoftware dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>, Richard Henderson <rth at redhat dot com>, Alexandre Oliva <aoliva at redhat dot com>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 22 Dec 2001 14:52:05 -0500 (EST)
- Subject: Re: conversions between vectors
On 22 Dec 2001, Aldy Hernandez wrote:
> > > c2 = __builtin_vector_add_v4si_unsigned (a2, b2);
> > >
> > > even if both builtins map to the same exact machine instruction.
> > If both are signed, or both unsigned, surely programmers will just use the
> > + operator?
> we have no support for any kind of operations on vectors.
Well, actually, this isn't quite right.
We have support for them, the type checking just disallows it.
> dan berlin
> had a patch for + and - a few weeks ago, but no one approved AFAICT.
Right, and all the patch does is tell the type checker "This isn't an
The rest is automagic based on the right expanders existing (this is why
you name the vector add ops addv4sf3, etc).
The patch that fixed genopinit so that it noticed these expanders is
already in and works.
> > Signed addition and unsigned addition are different in C; in signed
> > addition, overflow is undefined behaviour and GCC will optimise on the
> > basis that it is undefined. Thus the functions have conceptually
> > different behaviour.
> from what i've seen in vector extensions, signed and unsigned additions
> for vector types are the same. i don't think there's overflow.
> > The programmers should normally be using the much less cumbersome +
> i absolutely agree. so, let's get Dan's patch approved.
> > operator between two vectors of the same type. If they want to add a
> > signed to an unsigned - yes, make them explictly convert one to the other
> > rather than repeating the problems of the type system for the standard
> > types.
> for operations between signed and unsigned in which one is signed and
> the other unsigned, yes, i agree. provided we have + - etc available.
> this would be great.
> however, what do you do for a function:
> void foo (vector int, vector int);
> that operates on vector int's but has the same effect for vector
> unsigned as for vector signed? are you going to explicitly require a
> cast? that's the part i don't like.
> Aldy Hernandez E-mail: email@example.com
> Professional Gypsy
> Red Hat, Inc.