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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 19 06:09:27 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,
----------------
dtcxzyw wrote:

FYI, there is the length distribution of strcmp/strncmp with constant strings in my [testsuite](getConstantStringInfo):

```
Len (including '\0') Count
2 1041
3 1435
4 1531
5 2303
6 1667
7 1704
8 1541
9 1257
10 1043
11 922
12 704
13 652
14 734
15 533
16 490
17 406
18 400
19 277
20 289
21 194
22 188
23 163
24 3567
25 123
26 118
27 81
28 73
29 62
30 49
31 31
32 53
```

It would be better to set the threshold to 8 or 16.


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


More information about the llvm-commits mailing list