[llvm] [AArch64] Don't tail call memset if it would convert to a bzero. (PR #98969)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 15:43:39 PDT 2024


================
@@ -685,7 +687,10 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
          (IID == Intrinsic::memmove &&
           TLI.getLibcallName(RTLIB::MEMMOVE) == StringRef("memmove")) ||
          (IID == Intrinsic::memset &&
-          TLI.getLibcallName(RTLIB::MEMSET) == StringRef("memset"))) &&
+          TLI.getLibcallName(RTLIB::MEMSET) == StringRef("memset") &&
+          (!isa<ConstantInt>(Call->getOperand(1)) ||
+           !cast<ConstantInt>(Call->getOperand(1))->isZero() ||
+           !TLI.getLibcallName(RTLIB::BZERO)))) &&
----------------
efriedma-quic wrote:

Currently, isTailCall is a parameter to SelectionDAG::getMemset(), but it doesn't really need to be; SelectionDAGBuilder::visitIntrinsicCall just calls isInTailCallPosition so it can pass the result into getMemset().  Instead, we can just call isInTailCallPosition from getMemset(), once we know whether we're calling bzero or memset, and we can pass that information down.

https://github.com/llvm/llvm-project/pull/98969


More information about the llvm-commits mailing list