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