[llvm] r358287 - Add options for MaxLoadsPerMemcmp(OptSize).

Hiroshi Yamauchi via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 08:05:47 PDT 2019


Author: yamauchi
Date: Fri Apr 12 08:05:46 2019
New Revision: 358287

URL: http://llvm.org/viewvc/llvm-project?rev=358287&view=rev
Log:
Add options for MaxLoadsPerMemcmp(OptSize).

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60587

Modified:
    llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp

Modified: llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp?rev=358287&r1=358286&r2=358287&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp (original)
+++ llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp Fri Apr 12 08:05:46 2019
@@ -36,6 +36,14 @@ static cl::opt<unsigned> MemCmpEqZeroNum
     cl::desc("The number of loads per basic block for inline expansion of "
              "memcmp that is only being compared against zero."));
 
+static cl::opt<unsigned> MaxLoadsPerMemcmp(
+    "max-loads-per-memcmp", cl::Hidden,
+    cl::desc("Set maximum number of loads used in expanded memcmp"));
+
+static cl::opt<unsigned> 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, c
   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




More information about the llvm-commits mailing list