<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks, Alexey. In that case, do you have any thoughts on the original email in this thread?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
 -Hal</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hal Finkel<br>
Lead, Compiler Technology and Programming Languages<br>
Leadership Computing Facility<br>
Argonne National Laboratory</div>
</span></font></div>
</div>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Bader, Alexey <alexey.bader@intel.com><br>
<b>Sent:</b> Tuesday, May 19, 2020 1:48 PM<br>
<b>To:</b> Finkel, Hal J. <hfinkel@anl.gov>; Anastasia Stulova <Anastasia.Stulova@arm.com>; Keane, Erich <erich.keane@intel.com>; Min-Yih Hsu <minyihh@uci.edu>; cfe-dev (cfe-dev@lists.llvm.org) <cfe-dev@lists.llvm.org><br>
<b>Cc:</b> nd <nd@arm.com><br>
<b>Subject:</b> RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</font>
<div> </div>
</div>
<div lang="RU">
<div class="x_WordSection1">
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="">Yes, we do implement these rules for OpenCL and they are applied to all OpenCL versions.</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""><a href="https://godbolt.org/z/YH6ExF">https://godbolt.org/z/YH6ExF</a></span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""> </span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style=""> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span lang="EN-US">From:</span></b><span lang="EN-US"> cfe-dev <cfe-dev-bounces@lists.llvm.org>
<b>On Behalf Of </b>Finkel, Hal J. via cfe-dev<br>
<b>Sent:</b> Tuesday, May 19, 2020 8:36 PM<br>
<b>To:</b> Anastasia Stulova <Anastasia.Stulova@arm.com>; Keane, Erich <erich.keane@intel.com>; Min-Yih Hsu <minyihh@uci.edu>; clang developer list <cfe-dev@lists.llvm.org><br>
<b>Cc:</b> nd <nd@arm.com><br>
<b>Subject:</b> Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></p>
</div>
</div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Thanks, Anastasia. I have certainly used the ext_vector_type types outside of OpenCL mode in the past. Do we currently implement the OpenCL 2 ternary operator rules for these vectors?</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> -Hal</span></p>
</div>
<div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div id="x_Signature">
<div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:10.0pt">Hal Finkel<br>
Lead, Compiler Technology and Programming Languages<br>
Leadership Computing Facility<br>
Argonne National Laboratory</span></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="color:black">From:</span></b><span style="color:black"> Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com">Anastasia.Stulova@arm.com</a>><br>
<b>Sent:</b> Tuesday, May 19, 2020 12:30 PM<br>
<b>To:</b> Keane, Erich <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu">minyihh@uci.edu</a>>; Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>; clang developer list <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Cc:</b> nd <<a href="mailto:nd@arm.com">nd@arm.com</a>><br>
<b>Subject:</b> Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span>
</p>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
</div>
</div>
<div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">I see ext_vector_type as a Clang extension that implements OpenCL rules under OpenCL mode. I believe there are areas where it behaves slightly differently if it's used in non-OpenCL code. I am not aware of details,
 but I believe it is used outside of OpenCL mode too.</span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black">Anastasia</span></p>
</div>
<div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_x_divRplyFwdMsg">
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="color:black">From:</span></b><span style="color:black"> cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.org</a>> on behalf of Finkel, Hal J. via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Sent:</b> 19 May 2020 14:22<br>
<b>To:</b> Keane, Erich <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu">minyihh@uci.edu</a>><br>
<b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span>
</p>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
</div>
</div>
<div>
<blockquote style="border:none #C8C8C8 1.0pt; border-left:solid #C8C8C8 2.25pt; padding:0cm 0cm 0cm 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<span style="color:#666666">
<hr size="2" width="98%" align="center">
</span></div>
<div id="x_x_x_divRplyFwdMsg">
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span style="color:black">From:</span></b><span style="color:black"> Keane, Erich <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>><br>
<b>Sent:</b> Tuesday, May 19, 2020 8:10 AM<br>
<b>To:</b> Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu">minyihh@uci.edu</a>><br>
<b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</span><span style="color:#666666">
</span></p>
<div>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">What is the intent with the ext-vector-types? </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
</div>
</blockquote>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
That's a really good question. I've always thought of them as a slightly-more-convenient version of the vector types, although I suppose that they're really supposed to be OpenCL vectors. The Clang extension docs say, "OpenCL vector types are created using
 the ext_vector_type attribute. It supports the V.xyzw syntax and other tidbits as seen in OpenCL." Thus, for OpenCL, I suppose that it is supposed to do this: <a href="https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_C.html#operators-ternary-selection">https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_C.html#operators-ternary-selection</a></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
 -Hal</p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
 </p>
<blockquote style="border:none #C8C8C8 1.0pt; border-left:solid #C8C8C8 2.25pt; padding:0cm 0cm 0cm 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> It seems to me that it is an incompatible extension without anyone really maintaining them, and slightly different SEMA rules (for seemingly no reason).</span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">The conditional operator for the vector_size value was implemented as a GCC compatibility option, but no such motivation existed for ext-vetctor-types.</span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">That said, the semantic analysis for this in ext-vector-types is sufficiently different that it wasn’t possible to combine implementations.  The rules had diverged significantly at one point, so there wasn’t really a
 way to do so compatibly.</span></p>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span lang="EN-US" style="color:#666666">From:</span></b><span lang="EN-US" style="color:#666666"> Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>
<br>
<b>Sent:</b> Tuesday, May 19, 2020 6:05 AM<br>
<b>To:</b> Keane, Erich <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu">minyihh@uci.edu</a>><br>
<b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></p>
</div>
</div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black">In general, I don't like to see features supported by not-ext-vector types that are not supported by ext-vector types.</span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black"> </span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black">That having been said, is this related to our discussion on bool vectors:</span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black"> </span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black">  <a href="http://lists.llvm.org/pipermail/cfe-dev/2020-May/065434.html">http://lists.llvm.org/pipermail/cfe-dev/2020-May/065434.html</a></span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black"> </span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black"> -Hal</span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black"> </span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div id="x_x_x_x_Signature">
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:10.0pt; color:#666666">Hal Finkel<br>
Lead, Compiler Technology and Programming Languages<br>
Leadership Computing Facility<br>
Argonne National Laboratory</span><span lang="EN-US" style="color:#666666"></span></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="font-size:12.0pt; color:black"> </span><span lang="EN-US" style="color:#666666"></span></p>
</div>
<div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;text-align:center">
<span lang="EN-US" style="color:#666666">
<hr size="2" width="98%" align="center">
</span></div>
<div id="x_x_x_x_divRplyFwdMsg">
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span lang="EN-US" style="color:black">From:</span></b><span lang="EN-US" style="color:black"> cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.org</a>> on behalf of Min-Yih Hsu via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Sent:</b> Friday, May 8, 2020 1:17 PM<br>
<b>To:</b> Keane, Erich <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>><br>
<b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span><span lang="EN-US" style="color:#666666">
</span></p>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Interesting….then I think the question simply becomes whether we should support it in ext_vector_type as well.
</span></p>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Thanks for the pointer</span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">-Min</span></p>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;margin-bottom:12.0pt">
<span lang="EN-US" style="color:#666666"> </span></p>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">On May 8, 2020, at 11:04 AM, Keane, Erich <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>> wrote:</span></p>
</div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
<div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Note that this was implemented for non-ext-vector types here:</span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"><a href="https://github.com/llvm/llvm-project/commit/349636d2bfc39a5c81a835a95d203a42d9f9301a"><span style="color:purple">https://github.com/llvm/llvm-project/commit/349636d2bfc39a5c81a835a95d203a42d9f9301a</span></a></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Which matches the GCC version. <span class="x_xxxxapple-converted-space"> </span></span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">The attribute is vector_size, not ext_vector_type however.</span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Otherwise, it does everything you’re proposing (like I said, just with a more portable vector-type definition).</span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<b><span lang="EN-US" style="color:#666666">From:</span></b><span class="x_xxxxapple-converted-space"><span lang="EN-US" style="color:#666666"> </span></span><span lang="EN-US" style="color:#666666">cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.org</a>><span class="x_xxxxapple-converted-space"> </span><b>On
 Behalf Of<span class="x_xxxxapple-converted-space"> </span></b>Min-Yih Hsu via cfe-dev<br>
<b>Sent:</b><span class="x_xxxxapple-converted-space"> </span>Friday, May 8, 2020 10:58 AM<br>
<b>To:</b><span class="x_xxxxapple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<b>Subject:</b><span class="x_xxxxapple-converted-space"> </span>[cfe-dev] [RFC] Ternary operator with vector type predicate</span></p>
</div>
</div>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Hi folks,</span></p>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">In clang’s vector extension, the ternary operator (?:) is able to select from two vector type values based on the boolean type predicate. For example:</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">```</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">typedef float float4 __attribute__((ext_vector_type(4)));</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">float4 foo(bool cond, float4 a, float4 b) {</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">  return cond? a : b;</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">}</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">```</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">However, clang currently doesn’t support vector type values as the predicates. So code shown below won’t compile:</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">```</span></p>
</div>
</div>
<div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">float4 foo(float4 a, float4 b) {</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">  return a > b? a : b;</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">}</span></p>
</div>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">```</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Which is essentially just a max function that can be implemented by hardware instructions (vmaxps in Intel AVX for example) efficiently.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">I’m proposing to support vector type values as predicates in the ternary operator: If the predicate value has vector type, each of its element would be converted to bool before being used to select corresponding elements
 from the second or third operands. Note that this is exactly what GCC is doing right now [1] in their vector extensions.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">On the (IR) codegen side, since the IR `select`, `icmp`, and `fcmp` instruction all support vector type values as the operands, I don’t think there are much trouble in it.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Here are the reasons and some advantages:</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">1. It provides more flexibility for programmers to do conditional selections on vectors. Especially for cases that can be optimized by hardware instructions like the motivated example above.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">2. It will not break the current usages of ternary operator: If the predicate is a scalar value, it’s still sticking to the current model.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">3. If the goal of our extensions is aiming to “support a broad range of GCC extensions”. Then the behavior should also be as consistent as possible.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">I’ll try to come up with a patch for preview as soon as possible.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Also a slightly off-topic thing: In our document [2], the ternary operator has always been mis-typed as ‘:?’ Maybe we should fix it some times.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">Thanks for the feedbacks in advance.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">-Min</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">[1]: <a href="https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html"><span style="color:purple">https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html</span></a></span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666">[2]: <a href="https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors"><span style="color:purple">https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors</span></a></span></p>
</div>
</div>
</div>
</div>
</div>
<p class="x_xxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;">
<span lang="EN-US" style="color:#666666"> </span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>