<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);">
Makes sense! The change seems to be straight forward and it brings useful functionality.</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);">
Cheers,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Anastasia<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Min-Yih Hsu <minyihh@uci.edu><br>
<b>Sent:</b> 21 May 2020 17:04<br>
<b>To:</b> Anastasia Stulova <Anastasia.Stulova@arm.com><br>
<b>Cc:</b> Bader, Alexey <alexey.bader@intel.com>; Finkel, Hal J. <hfinkel@anl.gov>; Keane, Erich <erich.keane@intel.com>; cfe-dev (cfe-dev@lists.llvm.org) <cfe-dev@lists.llvm.org>; nd <nd@arm.com><br>
<b>Subject:</b> Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</font>
<div> </div>
</div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">Thanks for everyone’s feedback.
<div class=""><br class="">
</div>
<div class="">I think the bottom line is that the originally proposal works under OpenCL and gcc-style vector extension. Should we support it for ext_vector_type under non-OpenCL mode?</div>
<div class=""><br class="">
</div>
<div class="">Surprisingly the bug Anastasia pointed to was also asking the same question. Most of the comments there agreed with the approach and I didn’t see any comments against it in this thread. So I’ll cook a simple patch to turn on this switch for non-OpenCL
 mode for everyone’s review.</div>
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On May 20, 2020, at 2:49 PM, Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com" class="">Anastasia.Stulova@arm.com</a>> wrote:</div>
<br class="x_Apple-interchange-newline">
<div class="">
<div class="" style="font-size:12pt; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif">
Right, If OpenCL mode compilation flag is removed from the example that Alexey has given, the compilation fails!<br class="">
</div>
<div class="" style="font-size:12pt; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif">
<br class="">
</div>
<div class="" style="font-size:12pt; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif">
FYI, I just came across this old bug discussing similar issue:</div>
<div class="" style="font-size:12pt; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif">
<a href="https://bugs.llvm.org/show_bug.cgi?id=33103" id="LPlnk309398" class="">https://bugs.llvm.org/show_bug.cgi?id=33103</a><br class="">
</div>
<div id="x_appendonsend" class="" style="font-family:Helvetica; font-size:16px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
</div>
<div class="" style="font-size:12pt; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif">
<br class="">
</div>
<hr tabindex="-1" class="" style="font-family:Helvetica; font-size:16px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; display:inline-block; width:753.609375px">
<span class="" style="font-family:Helvetica; font-size:16px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; float:none; display:inline!important"></span>
<div id="x_divRplyFwdMsg" dir="ltr" class="" style="font-family:Helvetica; font-size:16px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<font face="Calibri, sans-serif" class="" style="font-size:11pt"><b class="">From:</b><span class="x_Apple-converted-space"> </span>Bader, Alexey <<a href="mailto:alexey.bader@intel.com" class="">alexey.bader@intel.com</a>><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>19 May 2020 20:31<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>>; Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com" class="">Anastasia.Stulova@arm.com</a>>; Keane, Erich
 <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>>; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>) <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</font>
<div class=""> </div>
</div>
<div lang="RU" class="" style="font-family:Helvetica; font-size:16px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<div class="x_x_WordSection1">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="">I never used this extensions in non-OpenCL mode, so I can’t predict what is the impact of the proposed changes.</span></div>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="">I just note that code snippet from the original email works in OpenCL mode as described in RFC with one very minor note:</span></div>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<ul type="disc" class="" style="margin-bottom:0cm; margin-top:0cm">
<li class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">I’m proposing to support vector type values as predicates in the ternary operator:<span class="x_Apple-converted-space"> </span><b class="">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><span class="x_Apple-converted-space"> </span>Note that this is exactly what GCC is doing right now [1] in their vector extensions.</span><span lang="EN-US" class=""></span></li></ul>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="">In OpenCL mode the comparison operator returns bitmask to enable bitwise operations (<a href="https://godbolt.org/z/F6ynx6" class="">https://godbolt.org/z/F6ynx6</a>):</span></div>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; background-color:rgb(255,255,254)">
<span lang="EN-US" class="" style="font-family:"Consolas,",serif">float4 foo(float4 a, float4 b, int4 *c) {</span></div>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; background-color:rgb(255,255,254)">
<span lang="EN-US" class="" style="font-family:"Consolas,",serif">  <span class="" style="background-color:yellow; background-position:initial initial; background-repeat:initial initial">int4 x = {</span></span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; color:rgb(9,134,88); background-color:yellow; background-position:initial initial; background-repeat:initial initial">1</span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; background-color:yellow">, </span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; color:rgb(9,134,88); background-color:yellow; background-position:initial initial; background-repeat:initial initial">2</span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; background-color:yellow">, </span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; color:rgb(9,134,88); background-color:yellow; background-position:initial initial; background-repeat:initial initial">3</span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; background-color:yellow">, </span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; color:rgb(9,134,88); background-color:yellow; background-position:initial initial; background-repeat:initial initial">4</span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; background-color:yellow">};</span></div>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; background-color:rgb(255,255,254)">
<span lang="EN-US" class="" style="font-family:"Consolas,",serif; background-color:yellow">  *c = (a < b) & x;</span><span lang="EN-US" class="" style="font-family:"Consolas,",serif"></span></div>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; background-color:rgb(255,255,254)">
<span lang="EN-US" class="" style="font-family:"Consolas,",serif">  </span><span lang="EN-US" class="" style="font-family:"Consolas,",serif; color:blue">return</span><span lang="EN-US" class="" style="font-family:"Consolas,",serif"> a > b? a : b;</span></div>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; background-color:rgb(255,255,254)">
<span class="" style="font-family:"Consolas,",serif">}</span></div>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; background-color:rgb(255,255,254)">
<span class="" style="font-family:"Consolas,",serif"> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="">and select is defined as<span class="x_Apple-converted-space"> </span></span></div>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<table class="x_x_MsoNormalTable" cellpadding="0" border="1" style="background-color:white; border:1pt solid rgb(216,216,206)">
<tbody class="">
<tr class="">
<td valign="top" class="" style="border:1pt solid rgb(216,216,206); background-color:rgb(237,242,242); padding:6.75pt 7.5pt; background-position:initial initial; background-repeat:initial initial">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)">gentype <b class="">select</b>(gentype <i class="">a</i>, gentype <i class="">b</i>, igentype <i class="">c</i>) gentype <b class="">select</b>(gentype <i class="">a</i>,
 gentype <i class="">b</i>, ugentype <i class="">c</i>)</span></div>
</td>
<td valign="top" class="" style="border:1pt solid rgb(216,216,206); background-color:rgb(237,242,242); padding:6.75pt 7.5pt; background-position:initial initial; background-repeat:initial initial">
<p class="x_x_MsoNormal" style="margin:0cm 0cm 9pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)">For each component of a vector type,</span></p>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 9pt; font-size:11pt; font-family:Calibri,sans-serif">
<i class=""><span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)">result[i]</span></i><span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)"> = if MSB of <i class="">c[i]</i> is
 set ? <i class="">b[i]</i> : <i class="">a[i]</i>.</span></p>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 9pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)">For a scalar type, <i class="">result</i> = <i class="">c</i> ? <i class="">b</i> : <i class="">a</i>.</span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:10pt; font-family:Consolas; color:rgb(38,67,87); background-color:white; background-position:initial initial; background-repeat:initial initial">igentype</span><span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)"> and </span><span lang="EN-US" class="" style="font-size:10pt; font-family:Consolas; color:rgb(38,67,87); background-color:white; background-position:initial initial; background-repeat:initial initial">ugentype</span><span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)"> must
 have the same number of elements and bits as </span><span lang="EN-US" class="" style="font-size:10pt; font-family:Consolas; color:rgb(38,67,87); background-color:white; background-position:initial initial; background-repeat:initial initial">gentype</span><sup class=""><span lang="EN-US" class="" style="font-size:9pt; font-family:Arial,sans-serif; color:rgb(109,110,113)">36</span></sup><span lang="EN-US" class="" style="font-size:12pt; font-family:Arial,sans-serif; color:rgb(109,110,113)">.</span></div>
</td>
</tr>
</tbody>
</table>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="">I guess, if we convert predicate elements to bool, we should get the same behavior.</span></div>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<div class="">
<div class="" style="border-style:solid none none; border-top-width:1pt; border-top-color:rgb(225,225,225); padding:3pt 0cm 0cm">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""><span class="x_Apple-converted-space"> </span>Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>><span class="x_Apple-converted-space"> </span><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Tuesday, May 19, 2020 9:50 PM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Bader, Alexey <<a href="mailto:alexey.bader@intel.com" class="">alexey.bader@intel.com</a>>; Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com" class="">Anastasia.Stulova@arm.com</a>>;
 Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>>; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>) <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div>
</div>
</div>
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt">Thanks, Alexey. In that case, do you have any thoughts on the original email in this thread?</span></div>
</div>
<div class="">
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> -Hal</span></div>
</div>
<div class="">
<div class="">
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div id="x_x_Signature" class="">
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:10pt">Hal Finkel<br class="">
Lead, Compiler Technology and Programming Languages<br class="">
Leadership Computing Facility<br class="">
Argonne National Laboratory</span></div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div class="x_x_MsoNormal" align="center" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; text-align:center">
<hr width="98%" size="2" align="center" class="">
</div>
<div id="x_x_divRplyFwdMsg" class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span class="" style="">From:</span></b><span class="" style=""><span class="x_Apple-converted-space"> </span>Bader, Alexey <<a href="mailto:alexey.bader@intel.com" class="">alexey.bader@intel.com</a>><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Tuesday, May 19, 2020 1:48 PM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>>; Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com" class="">Anastasia.Stulova@arm.com</a>>; Keane, Erich
 <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>>; cfe-dev (<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>) <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div>
<div class="">
<p class="x_x_MsoNormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="">Yes, we do implement these rules for OpenCL and they are applied to all OpenCL versions.</span></div>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""><a href="https://godbolt.org/z/YH6ExF" class="">https://godbolt.org/z/YH6ExF</a></span></div>
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class=""> </span></p>
<div class="">
<div class="" style="border-style:solid none none; border-top-width:1pt; border-top-color:rgb(225,225,225); padding:3pt 0cm 0cm">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""><span class="x_Apple-converted-space"> </span>cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" class="">cfe-dev-bounces@lists.llvm.org</a>><span class="x_Apple-converted-space"> </span><b class="">On
 Behalf Of<span class="x_Apple-converted-space"> </span></b>Finkel, Hal J. via cfe-dev<br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Tuesday, May 19, 2020 8:36 PM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com" class="">Anastasia.Stulova@arm.com</a>>; Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>>;
 Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>>; clang developer list <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div>
</div>
</div>
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt">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></div>
</div>
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> -Hal</span></div>
</div>
<div class="">
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div id="x_x_x_Signature" class="">
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:10pt">Hal Finkel<br class="">
Lead, Compiler Technology and Programming Languages<br class="">
Leadership Computing Facility<br class="">
Argonne National Laboratory</span></div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div class="x_x_MsoNormal" align="center" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; text-align:center">
<hr width="98%" size="2" align="center" class="">
</div>
<div id="x_x_x_divRplyFwdMsg" class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span class="" style="">From:</span></b><span class="" style=""><span class="x_Apple-converted-space"> </span>Anastasia Stulova <<a href="mailto:Anastasia.Stulova@arm.com" class="">Anastasia.Stulova@arm.com</a>><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Tuesday, May 19, 2020 12:30 PM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>>; Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>>;
 clang developer list <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div>
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt">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></div>
</div>
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt">Anastasia</span></div>
</div>
<div class="x_x_MsoNormal" align="center" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; text-align:center">
<hr width="98%" size="2" align="center" class="">
</div>
<div id="x_x_x_x_divRplyFwdMsg" class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span class="" style="">From:</span></b><span class="" style=""><span class="x_Apple-converted-space"> </span>cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" class="">cfe-dev-bounces@lists.llvm.org</a>> on behalf of Finkel, Hal J. via cfe-dev
 <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>19 May 2020 14:22<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><span class="x_Apple-converted-space"> </span><<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div>
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
</div>
</div>
<div class="">
<blockquote class="" style="border-style:none none none solid; border-left-width:2.25pt; border-left-color:rgb(200,200,200); padding:0cm 0cm 0cm 6pt; margin-left:4.8pt; margin-top:5pt; margin-bottom:5pt">
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="font-size:12pt"> </span></p>
</div>
<div class="">
<div class="x_x_MsoNormal" align="center" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; text-align:center">
<span class="" style="color:rgb(102,102,102)">
<hr width="98%" size="2" align="center" class="">
</span></div>
<div id="x_x_x_x_x_divRplyFwdMsg" class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span class="" style="">From:</span></b><span class="" style=""><span class="x_Apple-converted-space"> </span>Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Tuesday, May 19, 2020 8:10 AM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><span class="x_Apple-converted-space"> </span><<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</span><span class="" style="color:rgb(102,102,102)"></span></div>
<div class="">
<p class="x_x_xmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">What is the intent with the ext-vector-types? </span></div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
</div>
</blockquote>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<div class="" 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" class="">https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_C.html#operators-ternary-selection</a></div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 -Hal</div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 </p>
<blockquote class="" style="border-style:none none none solid; border-left-width:2.25pt; border-left-color:rgb(200,200,200); padding:0cm 0cm 0cm 6pt; margin-left:4.8pt; margin-top:5pt; margin-bottom:5pt">
<div class="">
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> 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></div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<div class="">
<div class="" style="border-style:solid none none; border-top-width:1pt; border-top-color:rgb(225,225,225); padding:3pt 0cm 0cm">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span lang="EN-US" class="" style="color:rgb(102,102,102)">From:</span></b><span lang="EN-US" class="" style="color:rgb(102,102,102)"><span class="x_Apple-converted-space"> </span>Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>><span class="x_Apple-converted-space"> </span><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Tuesday, May 19, 2020 6:05 AM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>>; Min-Yih Hsu <<a href="mailto:minyihh@uci.edu" class="">minyihh@uci.edu</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div>
</div>
</div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt">In general, I don't like to see features supported by not-ext-vector types that are not supported by ext-vector types.</span></div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt">That having been said, is this related to our discussion on bool vectors:</span></div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt">  <a href="http://lists.llvm.org/pipermail/cfe-dev/2020-May/065434.html" class="">http://lists.llvm.org/pipermail/cfe-dev/2020-May/065434.html</a></span></div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt"> -Hal</span></div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt"> </span></p>
</div>
<div id="x_x_x_x_x_x_Signature" class="">
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:10pt; color:rgb(102,102,102)">Hal Finkel<br class="">
Lead, Compiler Technology and Programming Languages<br class="">
Leadership Computing Facility<br class="">
Argonne National Laboratory</span></div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="font-size:12pt"> </span></p>
</div>
<div class="x_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" class="" style="color:rgb(102,102,102)">
<hr width="98%" size="2" align="center" class="">
</span></div>
<div id="x_x_x_x_x_x_divRplyFwdMsg" class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span lang="EN-US" class="" style="">From:</span></b><span lang="EN-US" class="" style=""><span class="x_Apple-converted-space"> </span>cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" class="">cfe-dev-bounces@lists.llvm.org</a>> on behalf
 of Min-Yih Hsu via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Friday, May 8, 2020 1:17 PM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>><br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><span class="x_Apple-converted-space"> </span><<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>><br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span><span lang="EN-US" class="" style="color:rgb(102,102,102)"></span></div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Interesting….then I think the question simply becomes whether we should support it in ext_vector_type as well.</span></div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Thanks for the pointer</span></div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">-Min</span></div>
<div class="">
<div class="" style="margin:0cm 0cm 12pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span><br class="x_webkit-block-placeholder">
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">On May 8, 2020, at 11:04 AM, Keane, Erich <<a href="mailto:erich.keane@intel.com" class="">erich.keane@intel.com</a>> wrote:</span></div>
</div>
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
<div class="">
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Note that this was implemented for non-ext-vector types here:</span></div>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"><a href="https://github.com/llvm/llvm-project/commit/349636d2bfc39a5c81a835a95d203a42d9f9301a" class=""><span class="" style="color:purple">https://github.com/llvm/llvm-project/commit/349636d2bfc39a5c81a835a95d203a42d9f9301a</span></a></span></div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Which matches the GCC version. <span class="x_x_xxxxxapple-converted-space"> </span></span></div>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">The attribute is vector_size, not ext_vector_type however.</span></div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Otherwise, it does everything you’re proposing (like I said, just with a more portable vector-type definition).</span></div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<div class="" style="border-style:solid none none; border-top-width:1pt; border-top-color:rgb(225,225,225); padding:3pt 0cm 0cm">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b class=""><span lang="EN-US" class="" style="color:rgb(102,102,102)">From:</span></b><span class="x_x_xxxxxapple-converted-space"><span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></span><span lang="EN-US" class="" style="color:rgb(102,102,102)">cfe-dev
 <<a href="mailto:cfe-dev-bounces@lists.llvm.org" class="">cfe-dev-bounces@lists.llvm.org</a>><span class="x_x_xxxxxapple-converted-space"> </span><b class="">On Behalf Of<span class="x_x_xxxxxapple-converted-space"> </span></b>Min-Yih Hsu via cfe-dev<br class="">
<b class="">Sent:</b><span class="x_x_xxxxxapple-converted-space"> </span>Friday, May 8, 2020 10:58 AM<br class="">
<b class="">To:</b><span class="x_x_xxxxxapple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">
<b class="">Subject:</b><span class="x_x_xxxxxapple-converted-space"> </span>[cfe-dev] [RFC] Ternary operator with vector type predicate</span></div>
</div>
</div>
</div>
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Hi folks,</span></div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">```</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">typedef float float4 __attribute__((ext_vector_type(4)));</span></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">float4 foo(bool cond, float4 a, float4 b) {</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">  return cond? a : b;</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">}</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">```</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">However, clang currently doesn’t support vector type values as the predicates. So code shown below won’t compile:</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">```</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">float4 foo(float4 a, float4 b) {</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">  return a > b? a : b;</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">}</span></div>
</div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">```</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Which is essentially just a max function that can be implemented by hardware instructions (vmaxps in Intel AVX for example) efficiently.</span></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Here are the reasons and some advantages:</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">I’ll try to come up with a patch for preview as soon as possible.</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">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></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">Thanks for the feedbacks in advance.</span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">-Min</span></div>
</div>
</div>
<div class="">
<div class="">
<p class="x_x_xxxxmsonormal" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)"> </span></p>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">[1]: <a href="https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html" class=""><span class="" style="color:purple">https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html</span></a></span></div>
</div>
</div>
<div class="">
<div class="">
<div class="" style="margin:0cm 0cm 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span lang="EN-US" class="" style="color:rgb(102,102,102)">[2]: <a href="https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors" class=""><span class="" style="color:purple">https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors</span></a></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>