From c27ff0d32db8662c8b1c0ab4ea611bc541fdb19f Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Fri, 12 Apr 2019 15:05:46 +0000 Subject: [PATCH] Add options for MaxLoadsPerMemcmp(OptSize). Reviewers: davidxl Reviewed By: davidxl Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60587 llvm-svn: 358287 --- llvm/lib/CodeGen/ExpandMemCmp.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/ExpandMemCmp.cpp b/llvm/lib/CodeGen/ExpandMemCmp.cpp index 6c80c170ce81..a3a979008dc0 100644 --- a/llvm/lib/CodeGen/ExpandMemCmp.cpp +++ b/llvm/lib/CodeGen/ExpandMemCmp.cpp @@ -36,6 +36,14 @@ static cl::opt MemCmpEqZeroNumLoadsPerBlock( cl::desc("The number of loads per basic block for inline expansion of " "memcmp that is only being compared against zero.")); +static cl::opt MaxLoadsPerMemcmp( + "max-loads-per-memcmp", cl::Hidden, + cl::desc("Set maximum number of loads used in expanded memcmp")); + +static cl::opt MaxLoadsPerMemcmpOptSize( + "max-loads-per-memcmp-opt-size", cl::Hidden, + cl::desc("Set maximum number of loads used in expanded memcmp for -Os/Oz")); + namespace { @@ -741,8 +749,13 @@ static bool expandMemCmp(CallInst *CI, const TargetTransformInfo *TTI, const auto *const Options = TTI->enableMemCmpExpansion(IsUsedForZeroCmp); if (!Options) return false; - const unsigned MaxNumLoads = - TLI->getMaxExpandSizeMemcmp(CI->getFunction()->hasOptSize()); + const unsigned MaxNumLoads = CI->getFunction()->hasOptSize() + ? (MaxLoadsPerMemcmpOptSize.getNumOccurrences() + ? MaxLoadsPerMemcmpOptSize + : TLI->getMaxExpandSizeMemcmp(true)) + : (MaxLoadsPerMemcmp.getNumOccurrences() + ? MaxLoadsPerMemcmp + : TLI->getMaxExpandSizeMemcmp(false)); unsigned NumLoadsPerBlock = MemCmpEqZeroNumLoadsPerBlock.getNumOccurrences() ? MemCmpEqZeroNumLoadsPerBlock