<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Apr 30, 2010, at 5:09 AM, Anton Lokhmotov wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hello,<br><br>I've been investigating how Clang interprets operations on extended vectors<br>[those declared with __attribute__((ext_vector_type(n))], in particular with<br>respect to the OpenCL semantics, since<br><a href="http://clang.llvm.org/docs/LanguageExtensions.html#vectors">http://clang.llvm.org/docs/LanguageExtensions.html#vectors</a> implies that<br>extended vectors have some support for OpenCL constructs.<br><br>My conclusion is that Clang's behaviour with respect to OpenCL considerably<br>varies from producing wrong diagnostics to accepting invalid statements and<br>rejecting valid statements to silently producing wrong LLVM code.  Couple of<br>examples (all vector types have obvious definitions):<br><br>uchar4 vu = (uchar4) true;  <br><span class="Apple-tab-span" style="white-space:pre">    </span>// results in: (0x01, 0x01, 0x01, 0x01)<br><span class="Apple-tab-span" style="white-space:pre">   </span>// must be: (0xff, 0xff, 0xff, 0xff)<br><br>int4 vu = (uint4) vi; // disallowed in OpenCL, accepted by Clang<br></div></blockquote><div><br></div><div>This is intentional.</div><div><br></div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font>int4 via, vib, vic;<br>vic = (via == vib ? via : vib);<span class="Apple-tab-span" style="white-space:pre">       </span>// allowed in OpenCL, rejected by Clang:<br><span class="Apple-tab-span" style="white-space:pre">  </span>// error: used type 'int4' where arithmetic or pointer type is<br>required<br></div></blockquote><div><br></div><div>The patch for this has not been submitted back to TOT clang yet.  </div><br><blockquote type="cite"><div><br>short2 vs, vr; int i;<br>vr = vs < i;<br><span class="Apple-tab-span" style="white-space:pre">     </span>// down-conversion and vector widening: disallowed by OpenCL,<br>rejected by Clang:<br><span class="Apple-tab-span" style="white-space:pre"> </span>// error: can't convert between vector values of different size<br>('short2' and 'int')<br><span class="Apple-tab-span" style="white-space:pre">     </span>// (clearly, the error message could be more helpful)<br></div></blockquote><div><br></div><div>Patches welcome.</div><br><blockquote type="cite"><div><br>My question is whether it anyone has objections to making statements<br>involving extended vectors to have by default semantics consistent with<br>OpenCL or only have the OpenCL semantics when the LangOpts flag is enabled?<br></div></blockquote><div><br></div><div>Extended Vectors are meant to support OpenCL-ish operations, but not enforce OpenCL error semantics all the time.</div><div><br></div><div>Nate</div></div></body></html>