add some notes for simplifylibcalls optimizations

llvm-svn: 61385
This commit is contained in:
Chris Lattner 2008-12-23 20:52:52 +00:00
parent 6ab6dc75ef
commit 8a35adf3a5
1 changed files with 25 additions and 0 deletions

View File

@ -1461,3 +1461,28 @@ void foo (int a, struct T b)
//===---------------------------------------------------------------------===//
simplifylibcalls should do several optimizations for strspn/strcspn:
strcspn(x, "") -> strlen(x)
strcspn("", x) -> 0
strspn("", x) -> 0
strspn(x, "") -> strlen(x)
strspn(x, "a") -> strchr(x, 'a')-x
strcspn(x, "a") -> inlined loop for up to 3 letters (similarly for strspn):
size_t __strcspn_c3 (__const char *__s, int __reject1, int __reject2,
int __reject3) {
register size_t __result = 0;
while (__s[__result] != '\0' && __s[__result] != __reject1 &&
__s[__result] != __reject2 && __s[__result] != __reject3)
++__result;
return __result;
}
This should turn into a switch on the character. See PR3253 for some notes on
codegen.
456.hmmer apparently uses strcspn and strspn a lot. 471.omnetpp uses strspn.
//===---------------------------------------------------------------------===//