[llvm] [InstCombine] Convert mem intrinsic with null into a noop (PR #100388)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 07:30:35 PDT 2024
================
@@ -1575,16 +1575,25 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
return eraseInstFromFunction(CI);
}
+ bool SrcIsNull = false;
// If we can determine a pointer alignment that is bigger than currently
// set, update the alignment.
if (auto *MTI = dyn_cast<AnyMemTransferInst>(MI)) {
if (Instruction *I = SimplifyAnyMemTransfer(MTI))
return I;
+ SrcIsNull = isa<ConstantPointerNull>(MTI->getRawSource());
} else if (auto *MSI = dyn_cast<AnyMemSetInst>(MI)) {
if (Instruction *I = SimplifyAnyMemSet(MSI))
return I;
}
+ // If src/dest is null, this memory intrinsic must be a noop.
+ if (!NullPointerIsDefined(MI->getFunction()) &&
----------------
nikic wrote:
Don't you also have to pass the address space?
https://github.com/llvm/llvm-project/pull/100388
More information about the llvm-commits
mailing list