<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">(when I said this is incorrect, I mean that letting it through and setting it to any value is incorrect, so I believe we are both incorrect).<div><br></div><div>Michael</div><div><br><div><div>On Dec 15, 2013, at 8:41 PM, Michael Gottesman <<a href="mailto:mgottesman@apple.com">mgottesman@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>On Dec 15, 2013, at 2:44 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br><br><blockquote type="cite">On 2013 Dec 15, at 13:58, Michael Gottesman <<a href="mailto:mgottesman@apple.com">mgottesman@apple.com</a>> wrote:<br><br><blockquote type="cite">The comment could be made clearer clearing up those issues. I am going to fix up those comments in a bit.<br></blockquote><br>Thanks!  It might be enough to list the input and expected output of the<br>degenerate cases and let the reader confirm the logic.<br><br><blockquote type="cite">I was avoiding the unnecessary branch. I think with a fixed up comment this will be clear.<br></blockquote><br>Ah -- I’d missed that the branch in std::min() gets optimized away.<br><br><blockquote type="cite">I have no problem adding these test cases.<br></blockquote><br>I thought of another degenerate case, and unfortunately I think the<br>current code gets the wrong answer:<br><br>- APInt(1, 1).nearestLogBase2() == 0 // lg(1) should give 0, not 1.<br></blockquote><br>This is incorrect since log2 is not a well defined operation in Z/Z_1. If one defines log2(x) as the largest N such that 2^N < x then since in Z/Z_1, 2^N = 0^N, N could be any number. In reality we should probably add in an assertion to make sure that the routines are only called if the BitWidth is > 1.<br><br>Michael<br><br><blockquote type="cite"><br>Duncan</blockquote></div></blockquote></div><br></div></body></html>