[PATCH] Add __builtin_convertvector

Eli Friedman eli.friedman at gmail.com
Tue Sep 17 14:05:14 PDT 2013


On Tue, Sep 17, 2013 at 2:02 PM, Hal Finkel <hfinkel at anl.gov> wrote:

> ----- Original Message -----
> >
> > On Mon, Sep 16, 2013 at 8:41 PM, hfinkel at anl.gov < hfinkel at anl.gov >
> > wrote:
> >
> > ================
> > Comment at: include/clang/AST/Expr.h:3474
> > @@ +3473,3 @@
> > +/// vector type of the same arity.
> > +class ConvertVectorExpr : public Expr { // Should this be an
> > ExplicitCastExpr?
> > +private:
> > ----------------
> >
> > Eli Friedman wrote:
> > > No, this should not be a CastExpr.
> > Okay; I copied this comment from the AsTypeExpr node, so we should
> > probably remove it from there too.
> >
> >
> >
> > Okay.
> >
> >
> >
> >
> > ================
> > Comment at: lib/CodeGen/CGExprScalar.cpp:1011
> > @@ +1010,3 @@
> > + Res = Builder.CreateIntCast(Src, DstTy, InputSigned, "conv");
> > + else if (InputSigned)
> > + Res = Builder.CreateSIToFP(Src, DstTy, "conv");
> > ----------------
> >
> > Eli Friedman wrote:
> > > What if the destination type is a bool vector?
> > I think bool vectors are explicitly forbidden (in r190721).
> >
> >
> >
> > You can still use the ext_vector_type attribute to get one.
>
> Ah, thanks! The code generator seems to quite happily produce (and the IR
> validator accepts):
>
> %conv = fptoui <8 x float> %0 to <8 x i1>
>
> and:
>
> %conv = trunc <8 x i16> %0 to <8 x i1>
>
> will that be sufficient, do we need to do something special? Would it be
> better to explicitly compare against zero?
>
>
> Your documentation says it will do what a C cast would do (which is
compare against zero, not truncate).

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


More information about the cfe-commits mailing list