This patch adds strlen to LoopIdiomRecognize.cpp. It is the first part of 3 patches:
- Strlen loop idiom recognition
- strlen16 recognition and creation of new strlen16 intrinsic
- Folding of strlen/strlen16 call if they are only used for zero equality comparison (replace with load of first char)
Example that this recognizes:
unsigned strlen(char *Str) {
char *Src = Str;
if (!Src)
return 0;
for (; *Src;)
Src++;
return Src - Str;
}
Can you add similar statistic for strlen?