[PATCH] Allow casts of mixed-size same-arity vectors

Eli Friedman eli.friedman at gmail.com
Thu Sep 12 14:23:42 PDT 2013


On Thu, Sep 12, 2013 at 2:14 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> ----- Original Message -----
> >
> > On Sep 12, 2013, at 2:08 PM, Hal Finkel <hfinkel at anl.gov> wrote:
> >
> > > ----- Original Message -----
> > >>
> > >> On Wed, Sep 11, 2013 at 3:34 PM, Hal Finkel < hfinkel at anl.gov >
> > >> wrote:
> > >>
> > >> ----- Original Message -----
> > >>> On Sep 11, 2013, at 3:29 PM, Hal Finkel < hfinkel at anl.gov >
> > >>> wrote:
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>> ----- Original Message -----
> > >>>
> > >>>
> > >>> ----- Original Message -----
> > >>>
> > >>>
> > >>> Hal —
> > >>>
> > >>> Am I understanding this correctly:
> > >>>
> > >>> vector4float x;
> > >>> vector4int16 y = (vector4int16)x; // this is a conversion
> > >>> vector4int32 z = (vector4int32)x; // this is a bitcast
> > >>>
> > >>> This seems confusing in the extreme.
> > >>>
> > >>> On the other hand, I don't really like the implied int-to-float
> > >>> bitcast semantics. Maybe it would be better to just add a warning
> > >>> for this case. What do you think?
> > >>>
> > >>> bitcast semantics for vector casts are an essential tool for SIMD
> > >>> programming. Essentially all warnings generated would be false
> > >>> positives.
> > >>
> > >> Do you specifically mean in OpenCL, or generally? (I've worked on
> > >> SIMD special function implementations, so I understand the
> > >> utility).
> > >>
> > >> OpenCL doesn't allow writing casts like this at all, if that's
> > >> what
> > >> you're asking; OpenCL requires using intrinsics.
> > >
> > > So is there already an intrinsic that does what I want here?
> >
> > In OpenCL there are ~5000 of them (IIRC), yes.
>
> OIC, all of the convert_* functions.
>
> I've been thinking about constructing a patch to implement
> __builtin_vectorconvert(type, value), do you think that is a reasonable
> approach?
>
>
You mean, as a generic replacement for intrinsics like _mm_cvtepi32_ps?
 That seems reasonable.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130912/46236a98/attachment.html>


More information about the cfe-commits mailing list