[PATCH] D123819: [InstCombine] Fold strlen and strnlen recursively.
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 3 03:52:30 PDT 2022
nikic added a comment.
As mentioned on the original review, I think we would be better off not passing the Bound to minStringLength() and instead doing one umin at the end -- this avoids the need to handle this in each branch. Though possibly I forgot some reason why that doesn't work from the previous discussion.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:714
(isa<GlobalVariable>(GEP->getOperand(0)) &&
- NullTermIdx == ArrSize - 1)) {
- Offset = B.CreateSExtOrTrunc(Offset, CI->getType());
- return B.CreateSub(ConstantInt::get(CI->getType(), NullTermIdx),
- Offset);
+ (NullTermIdx == ArrSize - 1) && (!Bound || MaxLen < UINT64_MAX))) {
+ // Fold strnlen(s + x, Bound) -> min(strlen(s) - x, Bound)
----------------
Why is this condition needed?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123819/new/
https://reviews.llvm.org/D123819
More information about the llvm-commits
mailing list