diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-09-29 22:29:12 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-09-29 22:29:12 +0000 |
commit | e260990fa19e3f5f2935a922868e80b83fb87524 (patch) | |
tree | 8779ac3b6fe0df1a5dc220215c6a1a16eeea387c /test/Transforms/SimplifyLibCalls | |
parent | 8cf6c60710c7924bcd0235f37e4d613f9abf7dc6 (diff) | |
download | llvm-e260990fa19e3f5f2935a922868e80b83fb87524.tar.gz llvm-e260990fa19e3f5f2935a922868e80b83fb87524.tar.bz2 llvm-e260990fa19e3f5f2935a922868e80b83fb87524.tar.xz |
Simplify the loop in StrChrOptimizer. FileCheckize test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115095 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyLibCalls')
-rw-r--r-- | test/Transforms/SimplifyLibCalls/StrChr.ll | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/test/Transforms/SimplifyLibCalls/StrChr.ll b/test/Transforms/SimplifyLibCalls/StrChr.ll index 50ca0a6edb..eaabeb2feb 100644 --- a/test/Transforms/SimplifyLibCalls/StrChr.ll +++ b/test/Transforms/SimplifyLibCalls/StrChr.ll @@ -1,26 +1,26 @@ ; Test that the StrChrOptimizer works correctly -; RUN: opt < %s -simplify-libcalls -S | \ -; RUN: not grep {call.*@strchr} +; RUN: opt < %s -simplify-libcalls -S | FileCheck %s ; This transformation requires the pointer size, as it assumes that size_t is ; the size of a pointer. target datalayout = "-p:64:64:64" -@hello = constant [14 x i8] c"hello world\5Cn\00" ; <[14 x i8]*> [#uses=1] -@null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=1] +@hello = constant [14 x i8] c"hello world\5Cn\00" +@null = constant [1 x i8] zeroinitializer declare i8* @strchr(i8*, i32) -declare i32 @puts(i8*) - -define i32 @main() { - %hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=2] - %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1] - %world = call i8* @strchr( i8* %hello_p, i32 119 ) ; <i8*> [#uses=1] - %ignore = call i8* @strchr( i8* %null_p, i32 119 ) ; <i8*> [#uses=0] - %len = call i32 @puts( i8* %world ) ; <i32> [#uses=1] - %index = add i32 %len, 112 ; <i32> [#uses=2] - %result = call i8* @strchr( i8* %hello_p, i32 %index ) ; <i8*> [#uses=0] +define i32 @foo(i32 %index) { + %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* @strchr(i8* %hello_p, i32 119) +; CHECK: getelementptr i8* %hello_p, i64 6 + %ignore = call i8* @strchr(i8* %null_p, i32 119) +; CHECK-NOT: call i8* strchr + %null = call i8* @strchr(i8* %hello_p, i32 0) +; CHECK: getelementptr i8* %hello_p, i64 13 + %result = call i8* @strchr(i8* %hello_p, i32 %index) +; CHECK: call i8* @memchr(i8* %hello_p, i32 %index, i64 14) ret i32 %index } |