[PATCH] D100870: [MemCpyOpt] Allow variable lengths in memcpy optimizer
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 20 11:34:37 PDT 2021
nikic added a comment.
Looks fine, I'd suggest a few more tests:
- For the two you already have, add negative tests where the size is dynamic and doesn't match.
- Add a memcpy from uninit alloca with dynamic size.
================
Comment at: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp:1437
M->getSourceAlign().valueOrOne());
- if (performCallSlotOptzn(M, M, M->getDest(), M->getSource(),
- CopySize->getZExtValue(), Alignment, C)) {
- LLVM_DEBUG(dbgs() << "Performed call slot optimization:\n"
- << " call: " << *C << "\n"
- << " memcpy: " << *M << "\n");
- eraseInstruction(M);
- ++NumMemCpyInstr;
- return true;
+ if (ConstantInt *CopySize = dyn_cast<ConstantInt>(M->getLength())) {
+ if (performCallSlotOptzn(M, M, M->getDest(), M->getSource(),
----------------
I'd move this check a bit higher (accessedBetween is more expensive).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D100870/new/
https://reviews.llvm.org/D100870
More information about the llvm-commits
mailing list