[PATCH] D109555: [APInt] Enable APInt to support zero bit integers.

Chris Lattner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 18:00:17 PDT 2021


lattner marked an inline comment as done.
lattner added inline comments.


================
Comment at: llvm/include/llvm/ADT/APInt.h:579
       BitWidth = RHS.BitWidth;
-      return clearUnusedBits();
+      return *this;
     }
----------------
craig.topper wrote:
> lattner wrote:
> > craig.topper wrote:
> > > Why don't we need to clearUnusedBits here?
> > I can split this out to a different patch if you prefer.  It just isn't needed.  RHS is already a well formed APInt, so it already has the right zero bits at the top.
> Couldn't `RHS` have more bits than `this` which would require the bits to be removed?
Nope. This is a copy ctor, we're taking both the new value and the new bitwidth, so the new value is already guaranteed to be normalized under the new bitwidth by the instance we're copying from.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109555



More information about the llvm-commits mailing list