Reid Spencer | f31918b | 2005-05-03 00:52:19 +0000 | [diff] [blame^] | 1 | ; Test that the StrNCmpOptimizer works correctly |
| 2 | ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*strncmp' |
Reid Spencer | d2db880 | 2005-05-03 00:50:43 +0000 | [diff] [blame] | 3 | |
| 4 | declare int %strncmp(sbyte*,sbyte*,int) |
| 5 | declare int %puts(sbyte*) |
| 6 | %hello = constant [6 x sbyte] c"hello\00" |
| 7 | %hell = constant [5 x sbyte] c"hell\00" |
| 8 | %null = constant [1 x sbyte] c"\00" |
| 9 | |
| 10 | implementation ; Functions: |
| 11 | |
| 12 | int %main () { |
| 13 | %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0 |
| 14 | %hell_p = getelementptr [5 x sbyte]* %hell, int 0, int 0 |
| 15 | %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0 |
| 16 | %temp1 = call int %strncmp(sbyte* %hello_p, sbyte* %hello_p,int 5) |
| 17 | %temp2 = call int %strncmp(sbyte* %null_p, sbyte* %null_p,int 0) |
| 18 | %temp3 = call int %strncmp(sbyte* %hello_p, sbyte* %null_p,int 0) |
| 19 | %temp4 = call int %strncmp(sbyte* %null_p, sbyte* %hello_p,int 0) |
| 20 | %temp5 = call int %strncmp(sbyte* %hell_p, sbyte* %hello_p,int 4) |
| 21 | %rslt1 = add int %temp1, %temp2 |
| 22 | %rslt2 = add int %rslt1, %temp3 |
| 23 | %rslt3 = add int %rslt2, %temp4 |
| 24 | %rslt4 = add int %rslt3, %temp5 |
| 25 | ret int %rslt4 |
| 26 | } |