<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 27, 2014 at 7:17 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><br><div class="gmail_quote">On Mon, Oct 27, 2014 at 7:07 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>Curiously, it looks like GCC is depending on definedness for 0 in its own headers: <a href="https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/lzcntintrin.h" target="_blank">https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/lzcntintrin.h</a></div><div><br></div><div>*shrug*</div></blockquote></div><br></span>I don't think that's really a justification for much of anything though.</div><div class="gmail_extra"><br></div><div class="gmail_extra">We should still add UBSan checks for this, and make our code correct according to the spec for these builtins.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Currently, I continue to prefer not using a builtin and instead defining the __lzcnt stuff with a ternary operator.</div></div>
</blockquote></div><br></div><div class="gmail_extra">That is my preference as well.</div><div class="gmail_extra"><br></div><div class="gmail_extra">If going forward we don't want to allow the 0 case to ever be defined, we should change the comment above isCLZForZeroUndef which currently says "on targets that support these operations in a way that provides well-defined results for zero without loss of performance, it is a good idea to avoid optimizing based on that undef behavior"; we should not claim it to be a "good idea" if usage of that hook is deprecated.</div><div class="gmail_extra"><br></div><div class="gmail_extra">-- Sean Silva</div></div>