From: Hiroshi Yamauchi Date: Fri, 12 Apr 2019 15:05:46 +0000 (+0000) Subject: Add options for MaxLoadsPerMemcmp(OptSize). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aae02cfe3c2d2cb4c62b68b665d361ecb394b4b9;p=llvm Add options for MaxLoadsPerMemcmp(OptSize). Reviewers: davidxl Reviewed By: davidxl Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60587 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358287 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/ExpandMemCmp.cpp b/lib/CodeGen/ExpandMemCmp.cpp index 6c80c170ce8..a3a979008dc 100644 --- a/lib/CodeGen/ExpandMemCmp.cpp +++ b/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