[PATCH] D150422: [ConstantFolding] fold integers whose bitwidth is greater than 63, and not multiplies of 8

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 03:28:08 PDT 2023


RKSimon added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:440
+      if (n <= IntBytes)
+        CurPtr[i] = (unsigned char)(Val.lshr(n * 8).getZExtValue());
       ++ByteOffset;
----------------
Val.extractBits(8, n * 8).getZextValue()


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:432
   if (auto *CI = dyn_cast<ConstantInt>(C)) {
-    if (CI->getBitWidth() > 64 ||
-        (CI->getBitWidth() & 7) != 0)
-      return false;
-
     uint64_t Val = CI->getZExtValue();
     unsigned IntBytes = unsigned(CI->getBitWidth()/8);
----------------
khei4 wrote:
> nikic wrote:
> > This is going to assert if the value inside the i128 is larger than 64-bit. It's necessary to work on the APInt representation instead.
> Thank you!! I was careless!
const APInt &Val


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

https://reviews.llvm.org/D150422



More information about the llvm-commits mailing list