Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | ; Test that the StrChrOptimizer works correctly |
| 2 | ; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \ |
| 3 | ; RUN: not grep {call.*%strchr} |
| 4 | |
| 5 | declare sbyte* %strchr(sbyte*,int) |
| 6 | declare int %puts(sbyte*) |
| 7 | %hello = constant [14 x sbyte] c"hello world\n\00" |
| 8 | %null = constant [1 x sbyte] c"\00" |
| 9 | |
| 10 | implementation ; Functions: |
| 11 | |
| 12 | int %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 ) |
| 18 | %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 |
| 22 | } |