This is an archive of the discontinued LLVM Phabricator instance.

[APInt] New member function setBitVal
ClosedPublic

Authored by foad on Sep 2 2020, 8:39 AM.

Diff Detail

Event Timeline

foad created this revision.Sep 2 2020, 8:39 AM
foad requested review of this revision.Sep 2 2020, 8:39 AM

LGTM

llvm/include/llvm/ADT/APInt.h
1454

I think setBitVal() might be better.

RKSimon added inline comments.
llvm/include/llvm/ADT/APInt.h
1454

+1

RKSimon added inline comments.Sep 2 2020, 10:11 AM
llvm/include/llvm/ADT/APInt.h
1454

Would it be simpler if we just did:

if (BitValue)
  setBit(BitPosition);
else
  clearBit(BitPosition);
foad added inline comments.Sep 2 2020, 11:28 AM
llvm/include/llvm/ADT/APInt.h
1454

OK. I was trying to reduce the number of conditional branches but maybe it's not helpful in this case.

foad updated this revision to Diff 289525.Sep 2 2020, 12:02 PM

Rename to setBitVal and change implementation.

foad retitled this revision from [APInt] New member function setBitTo to [APInt] New member function setBitVal.Sep 2 2020, 12:05 PM
andreadb accepted this revision.Sep 2 2020, 12:22 PM

Looks good to me.

This revision is now accepted and ready to land.Sep 2 2020, 12:22 PM
This revision was landed with ongoing or failed builds.Sep 2 2020, 1:57 PM
This revision was automatically updated to reflect the committed changes.