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 {
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