<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 27, 2014 at 9:16 PM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><p class="MsoNormal" style="margin-left:.5in">I can't find any documentation *at all* for lzcntintrin.h, so I can find no suggestion that its __lzcnt* functions would have defined behavior on an input of 0.<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><a name="14954fb3d0a35a65__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></a></p>
</span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I think it's not the exact header so much as the functions themselves that we should care about.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Intel documents _lzcnt_u32/64 as returning operand size for 0 input. Ditto tzcnt.  Here's the lzcnt reference:<u></u><u></u></span></p>
<p class="MsoNormal"><a href="https://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-67C6440B-D49E-4D7C-98A2-667E47ED63CC.htm" target="_blank"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">https://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-67C6440B-D49E-4D7C-98A2-667E47ED63CC.htm</span></a><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u></span></p></blockquote><div><br></div><div>These seem reasonable to support when compiling and targeting a microarch with support for the instructions.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Microsoft documentation claims that __lzcnt* returns the operand size for 0 input, while noting "If you run code that uses this intrinsic on hardware that does
 not support the lzcnt instruction, the results are unpredictable."<u></u><u></u></span></p>
<p class="MsoNormal"><a href="http://msdn.microsoft.com/en-us/library/vstudio/bb384809(v=vs.100).aspx" target="_blank"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">http://msdn.microsoft.com/en-us/library/vstudio/bb384809(v=vs.100).aspx</span></a></p></blockquote></div><br>While if we absolutely must due to compatibility, I would push hard to not support these functions unless targeting such hardware.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I find this particularly important because in the grander scheme of things *very little* x86 hardware in the world has lzcnt, and even less tzcnt. =[ Weak APIs like this seem really problematic there.</div></div>