Remove llvm-upgrade and update tests.
[oota-llvm.git] / test / Transforms / SimplifyLibCalls / StrChr.ll
1 ; Test that the StrChrOptimizer works correctly
2 ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | \
3 ; RUN:   not grep {call.*%strchr}
4
5 @hello = constant [14 x i8] c"hello world\5Cn\00"               ; <[14 x i8]*> [#uses=1]
6 @null = constant [1 x i8] zeroinitializer               ; <[1 x i8]*> [#uses=1]
7
8 declare i8* @strchr(i8*, i32)
9
10 declare i32 @puts(i8*)
11
12 define i32 @main() {
13         %hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0                ; <i8*> [#uses=2]
14         %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0           ; <i8*> [#uses=1]
15         %world = call i8* @strchr( i8* %hello_p, i32 119 )              ; <i8*> [#uses=1]
16         %ignore = call i8* @strchr( i8* %null_p, i32 119 )              ; <i8*> [#uses=0]
17         %len = call i32 @puts( i8* %world )             ; <i32> [#uses=1]
18         %index = add i32 %len, 112              ; <i32> [#uses=2]
19         %result = call i8* @strchr( i8* %hello_p, i32 %index )          ; <i8*> [#uses=0]
20         ret i32 %index
21 }
22