<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);">
Right, If OpenCL mode compilation flag is removed from the example that Alexey has given, the compilation fails!<br>
</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);">
FYI, I just came across this old bug discussing similar issue:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<a href="https://bugs.llvm.org/show_bug.cgi?id=33103" id="LPlnk309398">https://bugs.llvm.org/show_bug.cgi?id=33103</a><br>
</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 style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Bader, Alexey <alexey.bader@intel.com><br>
<b>Sent:</b> 19 May 2020 20:31<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 style="" lang="EN-US">I never used this extensions in non-OpenCL mode, so I can’t predict what is the impact of the proposed changes.</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US"> </span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US">I just note that code snippet from the original email works in OpenCL mode as described in RFC with one very minor note:</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US"> </span></p>
<ul style="margin-bottom: 0cm;margin-top:0cm" type="disc">
<li class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">I’m proposing to support vector type values as predicates in the ternary operator:
<b>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.</b> Note that this is exactly what GCC is doing right now [1] in their vector extensions.</span><span lang="EN-US"></span></li></ul>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US"> </span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US">In OpenCL mode the comparison operator returns bitmask to enable bitwise operations (https://godbolt.org/z/F6ynx6):</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US"> </span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;background:#FFFFFE">
<span style="font-family:"Consolas,",serif; color:black" lang="EN-US">float4 foo(float4 a, float4 b, int4 *c) {</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;background:#FFFFFE">
<span style="font-family:"Consolas,",serif; color:black" lang="EN-US">  <span style="background:yellow">int4 x = {</span></span><span style="font-family:"Consolas,",serif; color:#098658; background:yellow" lang="EN-US">1</span><span style="font-family:"Consolas,",serif; color:black; background:yellow" lang="EN-US">, </span><span style="font-family:"Consolas,",serif; color:#098658; background:yellow" lang="EN-US">2</span><span style="font-family:"Consolas,",serif; color:black; background:yellow" lang="EN-US">, </span><span style="font-family:"Consolas,",serif; color:#098658; background:yellow" lang="EN-US">3</span><span style="font-family:"Consolas,",serif; color:black; background:yellow" lang="EN-US">, </span><span style="font-family:"Consolas,",serif; color:#098658; background:yellow" lang="EN-US">4</span><span style="font-family:"Consolas,",serif; color:black; background:yellow" lang="EN-US">};</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;background:#FFFFFE">
<span style="font-family:"Consolas,",serif; color:black; background:yellow" lang="EN-US">  *c = (a < b) & x;</span><span style="font-family:"Consolas,",serif; color:black" lang="EN-US">
</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;background:#FFFFFE">
<span style="font-family:"Consolas,",serif; color:black" lang="EN-US">  </span><span style="font-family:"Consolas,",serif; color:blue" lang="EN-US">return</span><span style="font-family:"Consolas,",serif; color:black" lang="EN-US"> a > b? a : b;</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;background:#FFFFFE">
<span style="font-family:"Consolas,",serif; color:black">}</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;background:#FFFFFE">
<span style="font-family:"Consolas,",serif; color:black"> </span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US">and select is defined as </span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US"> </span></p>
<table class="x_MsoNormalTable" style="background:white; border:solid #D8D8CE 1.0pt" cellpadding="0" border="1">
<tbody>
<tr>
<td style="border:solid #D8D8CE 1.0pt; background:#EDF2F2; padding:6.75pt 7.5pt 6.75pt 7.5pt" valign="top">
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US">gentype <b>select</b>(gentype <i>a</i>, gentype <i>b</i>, igentype <i>c</i>) gentype <b>select</b>(gentype <i>a</i>, gentype <i>b</i>, ugentype <i>c</i>)</span></p>
</td>
<td style="border:solid #D8D8CE 1.0pt; background:#EDF2F2; padding:6.75pt 7.5pt 6.75pt 7.5pt" valign="top">
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;margin-bottom:9.0pt">
<span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US">For each component of a vector type,</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;margin-bottom:9.0pt">
<i><span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US">result[i]</span></i><span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US"> = if MSB of <i>c[i]</i> is set ? <i>b[i]</i> : <i>a[i]</i>.</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;margin-bottom:9.0pt">
<span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US">For a scalar type, <i>result</i> = <i>c</i> ? <i>b</i> : <i>a</i>.</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:10.0pt; font-family:Consolas; color:#264357; background:white" lang="EN-US">igentype</span><span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US"> and </span><span style="font-size:10.0pt; font-family:Consolas; color:#264357; background:white" lang="EN-US">ugentype</span><span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US"> must
 have the same number of elements and bits as </span><span style="font-size:10.0pt; font-family:Consolas; color:#264357; background:white" lang="EN-US">gentype</span><sup><span style="font-size:9.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US">36</span></sup><span style="font-size:12.0pt; font-family:"Arial",sans-serif; color:#6D6E71" lang="EN-US">.</span></p>
</td>
</tr>
</tbody>
</table>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US"> </span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US">I guess, if we convert predicate elements to bool, we should get the same behavior.</span></p>
<p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="" lang="EN-US"> </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"> Finkel, Hal J. <hfinkel@anl.gov>
<br>
<b>Sent:</b> Tuesday, May 19, 2020 9:50 PM<br>
<b>To:</b> Bader, Alexey <alexey.bader@intel.com>; 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</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, Alexey. In that case, do you have any thoughts on the original email in this thread?</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" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;text-align:center" align="center">
<hr width="98%" size="2" 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"> Bader, Alexey <<a href="mailto:alexey.bader@intel.com">alexey.bader@intel.com</a>><br>
<b>Sent:</b> Tuesday, May 19, 2020 1:48 PM<br>
<b>To:</b> Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>; Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com">Anastasia.Stulova@arm.com</a>>; 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>>; cfe-dev (<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>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_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span lang="EN-US">Yes, we do implement these rules for OpenCL and they are applied to all OpenCL versions.</span></p>
<p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span lang="EN-US"><a href="https://godbolt.org/z/YH6ExF">https://godbolt.org/z/YH6ExF</a></span></p>
<p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span lang="EN-US"> </span></p>
<p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span lang="EN-US"> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_xmsonormal" 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 <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.org</a>>
<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 <<a href="mailto:Anastasia.Stulova@arm.com">Anastasia.Stulova@arm.com</a>>; 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>>; 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>
</div>
<p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
 </p>
<div>
<p class="x_xmsonormal" 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_xmsonormal" 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_xmsonormal" 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_xmsonormal" 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_x_Signature">
<div>
<div>
<p class="x_xmsonormal" 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_xmsonormal" 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" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;text-align:center" align="center">
<hr width="98%" size="2" align="center">
</div>
<div id="x_x_divRplyFwdMsg">
<p class="x_xmsonormal" 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_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
 </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal" 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_xmsonormal" 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_xmsonormal" 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" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;text-align:center" align="center">
<hr width="98%" size="2" align="center">
</div>
<div id="x_x_x_divRplyFwdMsg">
<p class="x_xmsonormal" 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_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
 </p>
</div>
</div>
<div>
<blockquote style="border:none; 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_xmsonormal" 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" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;text-align:center" align="center">
<span style="color:#666666">
<hr width="98%" size="2" align="center">
</span></div>
<div id="x_x_x_x_divRplyFwdMsg">
<p class="x_xmsonormal" 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_xmsonormal" 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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">What is the intent with the ext-vector-types? </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
</div>
</blockquote>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
 </p>
<p class="x_xxxxmsonormal" 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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
 </p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
 -Hal</p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
 </p>
<blockquote style="border:none; 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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> 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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<b><span style="color:#666666" lang="EN-US">From:</span></b><span style="color:#666666" lang="EN-US"> 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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US">In general, I don't like to see features supported by not-ext-vector types that are not supported by ext-vector types.</span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US">That having been said, is this related to our discussion on bool vectors:</span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US">  <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></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US"> -Hal</span></p>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US"> </span></p>
</div>
<div id="x_x_x_x_x_Signature">
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:10.0pt; color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="font-size:12.0pt; color:black" lang="EN-US"> </span></p>
</div>
<div class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;text-align:center" align="center">
<span style="color:#666666" lang="EN-US">
<hr width="98%" size="2" align="center">
</span></div>
<div id="x_x_x_x_x_divRplyFwdMsg">
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<b><span style="color:black" lang="EN-US">From:</span></b><span style="color:black" lang="EN-US"> 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 style="color:#666666" lang="EN-US">
</span></p>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">Thanks for the pointer</span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">-Min</span></p>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;margin-bottom:12.0pt">
<span style="color:#666666" lang="EN-US"> </span></p>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
<div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">Note that this was implemented for non-ext-vector types here:</span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"><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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">Which matches the GCC version. <span class="x_xxxxxapple-converted-space"> </span></span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">The attribute is vector_size, not ext_vector_type however.</span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<b><span style="color:#666666" lang="EN-US">From:</span></b><span class="x_xxxxxapple-converted-space"><span style="color:#666666" lang="EN-US"> </span></span><span style="color:#666666" lang="EN-US">cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.org</a>><span class="x_xxxxxapple-converted-space"> </span><b>On
 Behalf Of<span class="x_xxxxxapple-converted-space"> </span></b>Min-Yih Hsu via cfe-dev<br>
<b>Sent:</b><span class="x_xxxxxapple-converted-space"> </span>Friday, May 8, 2020 10:58 AM<br>
<b>To:</b><span class="x_xxxxxapple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<b>Subject:</b><span class="x_xxxxxapple-converted-space"> </span>[cfe-dev] [RFC] Ternary operator with vector type predicate</span></p>
</div>
</div>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">Hi folks,</span></p>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">```</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">typedef float float4 __attribute__((ext_vector_type(4)));</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">float4 foo(bool cond, float4 a, float4 b) {</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">  return cond? a : b;</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">}</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">```</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">```</span></p>
</div>
</div>
<div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">float4 foo(float4 a, float4 b) {</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">  return a > b? a : b;</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">}</span></p>
</div>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">```</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">Here are the reasons and some advantages:</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">I’ll try to come up with a patch for preview as soon as possible.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">Thanks for the feedbacks in advance.</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">-Min</span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">[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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US">[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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: "Calibri", sans-serif;">
<span style="color:#666666" lang="EN-US"> </span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>