Page MenuHomePhabricator

[APInt] Introduce APIntOps::GetPositionOfMostSignificantDifferentBit()
ClosedPublic

Authored by lebedev.ri on Fri, Oct 25, 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.Fri, Oct 25, 11:03 AM
RKSimon added inline comments.Fri, Oct 25, 11:18 AM
llvm/unittests/ADT/APIntTest.cpp
2774

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

lebedev.ri added inline comments.Fri, Oct 25, 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.Sat, Oct 26, 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.Sat, Oct 26, 8:51 AM
xbolva00 added inline comments.
llvm/include/llvm/ADT/APInt.h
2227

or GetPosOfMostSignificantDifferentBit

lebedev.ri marked 2 inline comments as done.Sat, Oct 26, 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.