[PATCH] D87033: [APInt] New member function setBitTo

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 2 11:28:03 PDT 2020


foad added inline comments.


================
Comment at: llvm/include/llvm/ADT/APInt.h:1454
+  /// Set a given bit to a given value.
+  void setBitTo(unsigned BitPosition, bool BitValue) {
+    assert(BitPosition < BitWidth && "BitPosition out of range");
----------------
RKSimon wrote:
> RKSimon wrote:
> > lebedev.ri wrote:
> > > I think `setBitVal()` might be better.
> > +1
> Would it be simpler if we just did:
> ```
> if (BitValue)
>   setBit(BitPosition);
> else
>   clearBit(BitPosition);
> ```
OK. I was trying to reduce the number of conditional branches but maybe it's not helpful in this case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87033/new/

https://reviews.llvm.org/D87033



More information about the llvm-commits mailing list