[llvm] r197272 - [block-freq] Add the method APInt::nearestLogBase2().

Duncan P. N. Exon Smith dexonsmith at apple.com
Sun Dec 15 14:44:18 PST 2013

On 2013 Dec 15, at 13:58, Michael Gottesman <mgottesman at apple.com> wrote:

> The comment could be made clearer clearing up those issues. I am going to fix up those comments in a bit.

Thanks!  It might be enough to list the input and expected output of the
degenerate cases and let the reader confirm the logic.

> I was avoiding the unnecessary branch. I think with a fixed up comment this will be clear.

Ah -- I’d missed that the branch in std::min() gets optimized away.

> I have no problem adding these test cases.

I thought of another degenerate case, and unfortunately I think the
current code gets the wrong answer:

- APInt(1, 1).nearestLogBase2() == 0 // lg(1) should give 0, not 1.


More information about the llvm-commits mailing list