summaryrefslogtreecommitdiff
path: root/test/Transforms/SimplifyLibCalls
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-06-15 21:34:25 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-06-15 21:34:25 +0000
commit386e918438b72620e7c00ee1197bf6940bfe6cf8 (patch)
tree763b52882a5f8400354150eb40ae0335273384ba /test/Transforms/SimplifyLibCalls
parent2bbaf4d06eb08f488e6614059006e3d2615fded3 (diff)
downloadllvm-386e918438b72620e7c00ee1197bf6940bfe6cf8.tar.gz
llvm-386e918438b72620e7c00ee1197bf6940bfe6cf8.tar.bz2
llvm-386e918438b72620e7c00ee1197bf6940bfe6cf8.tar.xz
simplify-libcalls: fold strstr(a, b) == a -> strncmp(a, b, strlen(b)) == 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106047 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyLibCalls')
-rw-r--r--test/Transforms/SimplifyLibCalls/StrStr.ll12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyLibCalls/StrStr.ll b/test/Transforms/SimplifyLibCalls/StrStr.ll
index 2cac2d498c..eefd2e8006 100644
--- a/test/Transforms/SimplifyLibCalls/StrStr.ll
+++ b/test/Transforms/SimplifyLibCalls/StrStr.ll
@@ -46,3 +46,15 @@ entry:
; CHECK: @test4
; CHECK: ret i8* %P
}
+
+define i1 @test5(i8* %P, i8* %Q) nounwind readonly {
+entry:
+ %call = tail call i8* @strstr(i8* %P, i8* %Q) nounwind ; <i8*> [#uses=1]
+ %cmp = icmp eq i8* %call, %P
+ ret i1 %cmp
+; CHECK: @test5
+; CHECK: [[LEN:%[a-z]+]] = call {{i[0-9]+}} @strlen(i8* %Q)
+; CHECK: [[NCMP:%[a-z]+]] = call {{i[0-9]+}} @strncmp(i8* %P, i8* %Q, {{i[0-9]+}} [[LEN]])
+; CHECK: icmp eq {{i[0-9]+}} [[NCMP]], 0
+; CHECK: ret i1
+}