[llvm] [AggressiveInstCombine] Inline strcmp/strncmp (PR #89371)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 19 06:23:58 PDT 2024


================
@@ -922,6 +924,251 @@ static bool foldPatternedLoads(Instruction &I, const DataLayout &DL) {
   return true;
 }
 
+static cl::opt<unsigned> StrNCmpInlineThreshold(
+    "strncmp-inline-threshold", cl::init(3), cl::Hidden,
----------------
nikic wrote:

I don't think that increasing the threshold is profitable (unless one would make it PGO based maybe) due to code size growth. It's not unusual to have a lot of cold strcmp calls in a code base and expanding all of them would balloon code size (and likely compile time) without any performance benefit.

Think of something like old-school command line option parsing code, where you have a function which which checks for 50 different option names -- now imagine if each of those comparisons got an inline expansion!

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


More information about the llvm-commits mailing list