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

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 9 16:50:12 PDT 2021


craig.topper added inline comments.


================
Comment at: llvm/include/llvm/ADT/APInt.h:575
   APInt &operator=(const APInt &RHS) {
     // If the bitwidths are the same, we can avoid mucking with memory
     if (isSingleWord() && RHS.isSingleWord()) {
----------------
This comment is wrong. We aren't checking bitwidth, we're checking that both bitwidths are <=64, but not that they are the same.


================
Comment at: llvm/include/llvm/ADT/APInt.h:579
       BitWidth = RHS.BitWidth;
-      return clearUnusedBits();
+      return *this;
     }
----------------
Why don't we need to clearUnusedBits here?


================
Comment at: llvm/lib/Support/APInt.cpp:262
-APInt& APInt::operator*=(const APInt& RHS) {
-  assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
   *this = *this * RHS;
----------------
I assume you droped this because it's checked in operator*?


================
Comment at: llvm/lib/Support/APInt.cpp:1098
 APInt APInt::rotr(unsigned rotateAmt) const {
+  if (rotateAmt == 0)
+    return *this;
----------------
BitWidth?


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