<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">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="Apple-interchange-newline"><div class=""><div 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; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif;" class="">Right, If OpenCL mode compilation flag is removed from the example that Alexey has given, the compilation fails!<br class=""></div><div 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; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><br class=""></div><div 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; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif;" class="">FYI, I just came across this old bug discussing similar issue:</div><div 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; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><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="appendonsend" style="caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div><div 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; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif;" class=""><br class=""></div><hr tabindex="-1" style="caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none; display: inline-block; width: 753.609375px;" class=""><span style="caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span><div id="divRplyFwdMsg" dir="ltr" style="caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="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="Apple-converted-space"> </span>19 May 2020 20:31<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</font><div class=""> </div></div><div lang="RU" style="caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="x_WordSection1"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><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_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><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_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" style="margin-bottom: 0cm; margin-top: 0cm;" class=""><li class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">I’m proposing to support vector type values as predicates in the ternary operator:<span class="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="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_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><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_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: rgb(255, 255, 254);" class=""><span lang="EN-US" style="font-family: "Consolas,", serif;" class="">float4 foo(float4 a, float4 b, int4 *c) {</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: rgb(255, 255, 254);" class=""><span lang="EN-US" style="font-family: "Consolas,", serif;" class=""> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;" class="">int4 x = {</span></span><span lang="EN-US" style="font-family: "Consolas,", serif; color: rgb(9, 134, 88); background-color: yellow; background-position: initial initial; background-repeat: initial initial;" class="">1</span><span lang="EN-US" style="font-family: "Consolas,", serif; background-color: yellow;" class="">, </span><span lang="EN-US" style="font-family: "Consolas,", serif; color: rgb(9, 134, 88); background-color: yellow; background-position: initial initial; background-repeat: initial initial;" class="">2</span><span lang="EN-US" style="font-family: "Consolas,", serif; background-color: yellow;" class="">, </span><span lang="EN-US" style="font-family: "Consolas,", serif; color: rgb(9, 134, 88); background-color: yellow; background-position: initial initial; background-repeat: initial initial;" class="">3</span><span lang="EN-US" style="font-family: "Consolas,", serif; background-color: yellow;" class="">, </span><span lang="EN-US" style="font-family: "Consolas,", serif; color: rgb(9, 134, 88); background-color: yellow; background-position: initial initial; background-repeat: initial initial;" class="">4</span><span lang="EN-US" style="font-family: "Consolas,", serif; background-color: yellow;" class="">};</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: rgb(255, 255, 254);" class=""><span lang="EN-US" style="font-family: "Consolas,", serif; background-color: yellow;" class=""> *c = (a < b) & x;</span><span lang="EN-US" style="font-family: "Consolas,", serif;" class=""></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: rgb(255, 255, 254);" class=""><span lang="EN-US" style="font-family: "Consolas,", serif;" class=""> </span><span lang="EN-US" style="font-family: "Consolas,", serif; color: blue;" class="">return</span><span lang="EN-US" style="font-family: "Consolas,", serif;" class=""> a > b? a : b;</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: rgb(255, 255, 254);" class=""><span style="font-family: "Consolas,", serif;" class="">}</span></div><p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; background-color: rgb(255, 255, 254);"><span style="font-family: "Consolas,", serif;" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">and select is defined as<span class="Apple-converted-space"> </span></span></div><p class="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_MsoNormalTable" cellpadding="0" border="1" style="background-color: white; border: 1pt solid rgb(216, 216, 206);"><tbody class=""><tr class=""><td valign="top" 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;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class="">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" 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;" class=""><p class="x_MsoNormal" style="margin: 0cm 0cm 9pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class="">For each component of a vector type,</span></p><p class="x_MsoNormal" style="margin: 0cm 0cm 9pt; font-size: 11pt; font-family: Calibri, sans-serif;"><i class=""><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class="">result[i]</span></i><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class=""> = 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_MsoNormal" style="margin: 0cm 0cm 9pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class="">For a scalar type, <i class="">result</i> = <i class="">c</i> ? <i class="">b</i> : <i class="">a</i>.</span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Consolas; color: rgb(38, 67, 87); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">igentype</span><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class=""> and </span><span lang="EN-US" style="font-size: 10pt; font-family: Consolas; color: rgb(38, 67, 87); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">ugentype</span><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class=""> must have the same number of elements and bits as </span><span lang="EN-US" style="font-size: 10pt; font-family: Consolas; color: rgb(38, 67, 87); background-color: white; background-position: initial initial; background-repeat: initial initial;" class="">gentype</span><sup class=""><span lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class="">36</span></sup><span lang="EN-US" style="font-size: 12pt; font-family: Arial, sans-serif; color: rgb(109, 110, 113);" class="">.</span></div></td></tr></tbody></table><p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><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_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 style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""><span class="Apple-converted-space"> </span>Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>><span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Tuesday, May 19, 2020 9:50 PM<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div></div></div><p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> </p><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt;" class="">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_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt;" class=""> -Hal</span></div></div><div class=""><div class=""><p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div id="x_Signature" class=""><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt;" class="">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_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: center;"><hr width="98%" size="2" align="center" class=""></div><div id="x_divRplyFwdMsg" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span style="" class="">From:</span></b><span style="" class=""><span class="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="Apple-converted-space"> </span>Tuesday, May 19, 2020 1:48 PM<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div><div class=""><p class="x_MsoNormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> </p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Yes, we do implement these rules for OpenCL and they are applied to all OpenCL versions.</span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><a href="https://godbolt.org/z/YH6ExF" class="">https://godbolt.org/z/YH6ExF</a></span></div><p class="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_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 style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""><span class="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="Apple-converted-space"> </span><b class="">On Behalf Of<span class="Apple-converted-space"> </span></b>Finkel, Hal J. via cfe-dev<br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Tuesday, May 19, 2020 8:36 PM<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div></div></div><p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> </p><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt;" class="">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_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt;" class=""> -Hal</span></div></div><div class=""><div class=""><p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div id="x_x_Signature" class=""><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 10pt;" class="">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_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: center;"><hr width="98%" size="2" align="center" class=""></div><div id="x_x_divRplyFwdMsg" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span style="" class="">From:</span></b><span style="" class=""><span class="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="Apple-converted-space"> </span>Tuesday, May 19, 2020 12:30 PM<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span>nd <<a href="mailto:nd@arm.com" class="">nd@arm.com</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div><div class=""><p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> </p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt;" class="">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_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt;" class="">Anastasia</span></div></div><div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: center;"><hr width="98%" size="2" align="center" class=""></div><div id="x_x_x_divRplyFwdMsg" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span style="" class="">From:</span></b><span style="" class=""><span class="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="Apple-converted-space"> </span>19 May 2020 14:22<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><span class="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="Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div><div class=""><p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> </p></div></div><div class=""><blockquote 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;" class=""><div class=""><p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 12pt;" class=""> </span></p></div><div class=""><div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: center;"><span style="color: rgb(102, 102, 102);" class=""><hr width="98%" size="2" align="center" class=""></span></div><div id="x_x_x_x_divRplyFwdMsg" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span style="" class="">From:</span></b><span style="" class=""><span class="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="Apple-converted-space"> </span>Tuesday, May 19, 2020 8:10 AM<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><span class="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="Apple-converted-space"> </span>RE: [cfe-dev] [RFC] Ternary operator with vector type predicate</span><span style="color: rgb(102, 102, 102);" class=""></span></div><div class=""><p class="x_xmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">What is the intent with the ext-vector-types? </span></div><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </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><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> </p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""> -Hal</div><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"> </p><blockquote 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;" class=""><div class=""><div class=""><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> 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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">From:</span></b><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""><span class="Apple-converted-space"> </span>Finkel, Hal J. <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>><span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Tuesday, May 19, 2020 6:05 AM<br class=""><b class="">To:</b><span class="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="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="Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span></div></div></div><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="font-size: 12pt;" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">That having been said, is this related to our discussion on bool vectors:</span></div></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="font-size: 12pt;" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""> <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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="font-size: 12pt;" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""> -Hal</span></div></div><div class=""><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="font-size: 12pt;" class=""> </span></p></div><div id="x_x_x_x_x_Signature" class=""><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="font-size: 12pt;" class=""> </span></p></div><div class="x_MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: center;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""><hr width="98%" size="2" align="center" class=""></span></div><div id="x_x_x_x_x_divRplyFwdMsg" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" style="" class="">From:</span></b><span lang="EN-US" style="" class=""><span class="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="Apple-converted-space"> </span>Friday, May 8, 2020 1:17 PM<br class=""><b class="">To:</b><span class="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="Apple-converted-space"> </span><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><span class="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="Apple-converted-space"> </span>Re: [cfe-dev] [RFC] Ternary operator with vector type predicate</span><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""></span></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">Thanks for the pointer</span></div></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">-Min</span></div><div class=""><div style="margin: 0cm 0cm 12pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span><br class="webkit-block-placeholder"></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p><div class=""><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">Note that this was implemented for non-ext-vector types here:</span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""><a href="https://github.com/llvm/llvm-project/commit/349636d2bfc39a5c81a835a95d203a42d9f9301a" class=""><span style="color: purple;" class="">https://github.com/llvm/llvm-project/commit/349636d2bfc39a5c81a835a95d203a42d9f9301a</span></a></span></div></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">Which matches the GCC version. <span class="x_xxxxxapple-converted-space"> </span></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">The attribute is vector_size, not ext_vector_type however.</span></div></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">From:</span></b><span class="x_xxxxxapple-converted-space"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></span><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org" class="">cfe-dev-bounces@lists.llvm.org</a>><span class="x_xxxxxapple-converted-space"> </span><b class="">On Behalf Of<span class="x_xxxxxapple-converted-space"> </span></b>Min-Yih Hsu via cfe-dev<br class=""><b class="">Sent:</b><span class="x_xxxxxapple-converted-space"> </span>Friday, May 8, 2020 10:58 AM<br class=""><b class="">To:</b><span class="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_xxxxxapple-converted-space"> </span>[cfe-dev] [RFC] Ternary operator with vector type predicate</span></div></div></div></div><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">Hi folks,</span></div></div><div class=""><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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 style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">```</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">typedef float float4 __attribute__((ext_vector_type(4)));</span></div></div></div><div class=""><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">float4 foo(bool cond, float4 a, float4 b) {</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> return cond? a : b;</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">}</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">```</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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 style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">```</span></div></div></div><div class=""><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">float4 foo(float4 a, float4 b) {</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> return a > b? a : b;</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">}</span></div></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">```</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">Here are the reasons and some advantages:</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">I’ll try to come up with a patch for preview as soon as possible.</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">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_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">Thanks for the feedbacks in advance.</span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">-Min</span></div></div></div><div class=""><div class=""><p class="x_xxxxmsonormal" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" style="color: rgb(102, 102, 102);" class=""> </span></p></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">[1]: <a href="https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html" class=""><span style="color: purple;" class="">https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html</span></a></span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="color: rgb(102, 102, 102);" class="">[2]: <a href="https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors" class=""><span style="color: purple;" class="">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></body></html>