summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyLibCalls
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-09-29 21:50:51 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-09-29 21:50:51 +0000
commit06f25cfb334d6630fc5018260a78129f4b956bad (patch)
tree66fb1b4e452c842a40977cd62fab39144d73147c /test/Transforms/SimplifyLibCalls
parent1a30123b609d48ac50f9a9e088e55683df70cfc3 (diff)
downloadllvm-06f25cfb334d6630fc5018260a78129f4b956bad.tar.gz
llvm-06f25cfb334d6630fc5018260a78129f4b956bad.tar.bz2
llvm-06f25cfb334d6630fc5018260a78129f4b956bad.tar.xz
Teach SimplifyLibCalls how to optimize strrchr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115091 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyLibCalls')
-rw-r--r--test/Transforms/SimplifyLibCalls/StrRChr.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyLibCalls/StrRChr.ll b/test/Transforms/SimplifyLibCalls/StrRChr.ll
new file mode 100644
index 0000000000..2259fc0289
--- /dev/null
+++ b/test/Transforms/SimplifyLibCalls/StrRChr.ll
@@ -0,0 +1,23 @@
+; Test that the StrRChrOptimizer works correctly
+; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
+
+target datalayout = "-p:64:64:64"
+
+@hello = constant [14 x i8] c"hello world\5Cn\00"
+@null = constant [1 x i8] zeroinitializer
+
+declare i8* @strrchr(i8*, i32)
+
+define void @foo(i8* %bar) {
+ %hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0
+ %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
+ %world = call i8* @strrchr(i8* %hello_p, i32 119)
+; CHECK: getelementptr i8* %hello_p, i64 6
+ %ignore = call i8* @strrchr(i8* %null_p, i32 119)
+; CHECK-NOT: call i8* strrchr
+ %null = call i8* @strrchr(i8* %hello_p, i32 0)
+; CHECK: getelementptr i8* %hello_p, i64 13
+ %strchr = call i8* @strrchr(i8* %bar, i32 0)
+; CHECK: call i8* @strchr(i8* %bar, i32 0)
+ ret void
+}