blob: 2d4f5f2dac266912bb6df59955c9b8fa130bead8 [file] [log] [blame]
Reid Spencer34efdf82005-05-03 06:22:41 +00001; Test that the StrChrOptimizer works correctly
Reid Spencerc88e6812005-05-03 17:09:38 +00002; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*%strchr'
Reid Spencer34efdf82005-05-03 06:22:41 +00003
4declare sbyte* %strchr(sbyte*,int)
5declare int %puts(sbyte*)
6%hello = constant [14 x sbyte] c"hello world\n\00"
7%null = constant [1 x sbyte] c"\00"
8
9implementation ; Functions:
10
11int %main () {
12 %hello_p = getelementptr [14 x sbyte]* %hello, int 0, int 0
13 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
14
15 %world = call sbyte* %strchr(sbyte* %hello_p, int 119 )
16 %ignore = call sbyte* %strchr(sbyte* %null_p, int 119 )
Reid Spencerc88e6812005-05-03 17:09:38 +000017 %len = call int %puts(sbyte* %world)
18 %index = add int %len, 112
19 %result = call sbyte* %strchr(sbyte* %hello_p, int %index)
20 ret int %index
Reid Spencer34efdf82005-05-03 06:22:41 +000021}