This is an archive of the discontinued LLVM Phabricator instance.

[APInt] Introduce APIntOps::GetPositionOfMostSignificantDifferentBit()
ClosedPublic

Authored by lebedev.ri on Oct 25 2019, 11:03 AM.

Details

Summary

Compare two values, and if they are different, return the position of the
most significant bit that is different in the values.

Needed for D69387.

Diff Detail

Event Timeline

lebedev.ri created this revision.Oct 25 2019, 11:03 AM
RKSimon added inline comments.Oct 25 2019, 11:18 AM
llvm/unittests/ADT/APIntTest.cpp
2774

Doesn't this only run once for BitWidth = 8 ?

lebedev.ri added inline comments.Oct 25 2019, 11:23 AM
llvm/unittests/ADT/APIntTest.cpp
2774

Oops, forgot to undo that..

lebedev.ri marked 2 inline comments as done.

Improve test, NFC.

nikic accepted this revision.Oct 26 2019, 8:51 AM

LGTM, though I'd suggest a more compact name.

llvm/include/llvm/ADT/APInt.h
2227

The name seems a bit excessive -- I think GetMostSignificantDifferingBit would have the same information content.

This revision is now accepted and ready to land.Oct 26 2019, 8:51 AM
xbolva00 added inline comments.
llvm/include/llvm/ADT/APInt.h
2227

or GetPosOfMostSignificantDifferentBit

lebedev.ri marked 2 inline comments as done.Oct 26 2019, 1:20 PM

Thank you for the review!
I will go with the most short one,
Also, this needs a bit more tests, will add when committing.

This revision was automatically updated to reflect the committed changes.