This is the mail archive of the gcc-patches@gcc.gnu.org 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: patch: Re: rfc: auto-casted vector types


+   /* FIXME: We assume V2SI is the opaque type, so we accidentally
+      allow inter conversion to and from V2SI modes.  We could use
+      V1D1, and rewrite <spe.h> accordingly.  */
+   return t1 == V2SI_type_node || t2 == V2SI_type_node;

... I was kind of hoping you could fix this. It's the sort of thing that becomes increasingly hard to fix over time, because people start to write code that (perhaps unknowingly) depends on it.

It could be fixed by having a separate opaque_type_node which has the
same contents as *V2SI_type_node but a different address.

I thought about this some more, and I believe I see where the underlying problem lies. Nick (or Jim), please correct me if I'm wrong, since you wrote the code in question.


The reason we have the following line:

+ return t1 == V2SI_type_node || t2 == V2SI_type_node;

is because most of the builtins return V2SI:

#define __ev_addw(a,b) __builtin_spe_evaddw((__v2si) (a), (__v2si) (b))

and we want to be able to assign their value to any other simd type without a cast. The API actually has a definition of __ev_addw() like thus:

__ev64_opaque__ __ev_addw(__ev64_opaque, __ev64_opaque__);

__ev_addw is supposed to return an opaque type so we can copy it to and fro without a cast. Since __builtin_spe_evaddw returns a V2SI, we have the aforementioned line to ensure it behaves like an opaque (return t1 == V2SI, etc).

So... instead of hacking all over the place in perhaps the .md and .c file, why don't we instead cast the return types of all the builtins to __ev64_opaque__, and then remove the offending line Geoff pointed out. Like this:

#define __ev_addw(a,b) (__v2si)__builtin_spe_evaddw(etc, etc)

BTW, __v2si is just a macro define for __ev64_opaque__.

This way we only change the user include file, remove one line from rs6000_spe_vector_types_compatible(), and leave everything as is :-).

How does that sound?

Aldy


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