<div dir="ltr">On Mon, Sep 16, 2013 at 8:41 PM, <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><br>
<br>
================<br>
Comment at: include/clang/AST/Expr.h:3474<br>
@@ +3473,3 @@<br>
+/// vector type of the same arity.<br>
+class ConvertVectorExpr : public Expr { // Should this be an ExplicitCastExpr?<br>
+private:<br>
----------------<br>
</div><div class="im">Eli Friedman wrote:<br>
> No, this should not be a CastExpr.<br>
</div>Okay; I copied this comment from the AsTypeExpr node, so we should probably remove it from there too.<br></blockquote><div><br></div><div>Okay.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div class="im"><br>
================<br>
Comment at: lib/CodeGen/CGExprScalar.cpp:1011<br>
@@ +1010,3 @@<br>
+      Res = Builder.CreateIntCast(Src, DstTy, InputSigned, "conv");<br>
+    else if (InputSigned)<br>
+      Res = Builder.CreateSIToFP(Src, DstTy, "conv");<br>
----------------<br>
</div><div class="im">Eli Friedman wrote:<br>
> What if the destination type is a bool vector?<br>
</div>I think bool vectors are explicitly forbidden (in r190721).<br></blockquote><div><br></div><div>You can still use the ext_vector_type attribute to get one.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div class="im"><br>
================<br>
Comment at: lib/Sema/SemaExpr.cpp:4489<br>
@@ +4488,3 @@<br>
+                     << E->getSourceRange());<br>
+<br>
+  return Owned(new (Context) ConvertVectorExpr(E, DstTy, VK, OK, BuiltinLoc,<br>
----------------<br>
</div><div class="im">Eli Friedman wrote:<br>
> You might want to be careful exactly what vector types we accept here... but I can't think of anything you actually need to check for, so maybe not.<br>
</div>I *think* that everything relevant is checked in Sema::BuildExtVectorType and HandleVectorSizeAttr (in SemaType.cpp), and so checking that we have a vector type should be sufficient.<br>
<br>
I could add an assert here just to be on the safe side; something like assert(Ty->isBuiltinType() && !Ty->isBooleanType() && (Ty->isIntegerType() || Ty->->isRealFloatingType()) && "...");<br>
</blockquote><div><br></div><div>Okay.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><br>
================<br>
Comment at: lib/Sema/TreeTransform.h:9171<br>
@@ +9170,3 @@<br>
+  llvm_unreachable("Cannot transform convertVector expressions yet");<br>
+}<br>
+<br>
----------------<br>
</div><div class="im">Eli Friedman wrote:<br>
> It would be nice to fix this before committing.<br>
</div>Agreed; this is another thing coped from the AsTypeExpr code. How can I test this?<br><br></blockquote><div><br></div><div>This ought to trigger it:</div><div><br></div><div>typedef int int_v4 __attribute__((vector_size(16))); </div>
<div>typedef float float_v4 __attribute__((vector_size(16))); </div><div>template<typename T> T f(int_v4 x) { return __builtin_convertvector(x, T); }</div></div>float_v4 g(int_v4 x) { return f<float_v4>(x); }</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">-Eli</div></div>