[PATCH] D150422: [ConstantFolding] fold integers whose bitwidth is greater than 63, and not multiplies of 8
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 12 01:20:39 PDT 2023
nikic added a comment.
> (how can I confirm the correctness of not multiplies of 8 integers?)
We currently don't specify the precise memory contents for non-byte-sized integers, so it's not really possible to fold such cases now. (We only specify what happens if you store an i4 and load i4, but for example not what happens if you store i4 and then load i8.)
================
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);
----------------
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.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150422/new/
https://reviews.llvm.org/D150422
More information about the llvm-commits
mailing list