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

Hal Finkel hfinkel at anl.gov
Wed Sep 11 13:00:10 PDT 2013


----- 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.

Ah, this is an excellent point. That does seem confusing. Do you have an alternate suggestion? (would it be better to add some kind of __builtin_convert intrinsic?)

Thanks,
Hal

> 
> Thanks,
> – Steve
> 
> On Sep 11, 2013, at 12:04 PM, Hal Finkel <hfinkel at anl.gov> wrote:
> 
> > Hello,
> > 
> > Please review the attached patch which adds support for casting
> > between vector types with different sizes (but the same number of
> > vector elements). LLVM supports these conversions for the
> > underlying LLVM vector types (just as for the scalar types), and
> > this adds support in Clang, requiring minor modifications in Sema
> > and CodeGen.
> > 
> > For example, this patch allows the following to work:
> > 
> > typedef double vector4double __attribute__((__vector_size__(32)));
> > typedef float  vector4float  __attribute__((__vector_size__(16)));
> > 
> > vector4float flt_trunc(vector4double x) {
> >  return (vector4float) x;
> > }
> > 
> > On some targets the code generation for these conversions has been
> > optimized (autovectorization can produce these conversions), and
> > accessing these capabilities from Clang is important, for example,
> > when writing intrinsics headers (which, when possible, we prefer
> > to implement in terms of generic IR).
> > 
> > Thanks in advance,
> > Hal
> > 
> > --
> > Hal Finkel
> > Assistant Computational Scientist
> > Leadership Computing Facility
> > Argonne National Laboratory
> > <mixed-size-vec-casts.patch>_______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory




More information about the cfe-commits mailing list