add some notes for simplifylibcalls optimizations
authorChris Lattner <sabre@nondot.org>
Tue, 23 Dec 2008 20:52:52 +0000 (20:52 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 23 Dec 2008 20:52:52 +0000 (20:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61385 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/README.txt

index 2b7e9ed4ffd20c46d90452c02f100fb15e3af620..81b0f9cc23a362b11e71da397c607643d5999143 100644 (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.
+
+//===---------------------------------------------------------------------===//