Reid Spencer | 34efdf8 | 2005-05-03 06:22:41 +0000 | [diff] [blame] | 1 | ; Test that the StrChrOptimizer works correctly |
Reid Spencer | c88e681 | 2005-05-03 17:09:38 +0000 | [diff] [blame^] | 2 | ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*%strchr' |
Reid Spencer | 34efdf8 | 2005-05-03 06:22:41 +0000 | [diff] [blame] | 3 | |
| 4 | declare sbyte* %strchr(sbyte*,int) |
| 5 | declare int %puts(sbyte*) |
| 6 | %hello = constant [14 x sbyte] c"hello world\n\00" |
| 7 | %null = constant [1 x sbyte] c"\00" |
| 8 | |
| 9 | implementation ; Functions: |
| 10 | |
| 11 | int %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 Spencer | c88e681 | 2005-05-03 17:09:38 +0000 | [diff] [blame^] | 17 | %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 Spencer | 34efdf8 | 2005-05-03 06:22:41 +0000 | [diff] [blame] | 21 | } |