Chris Lattner | 475cfe4 | 2005-09-29 06:11:34 +0000 | [diff] [blame^] | 1 | ; Test that the memcmpOptimizer works correctly |
| 2 | ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*memcmp' && |
| 3 | ; RUN: llvm-as < %s | opt -simplify-libcalls -disable-output |
| 4 | |
| 5 | declare int %memcmp(sbyte*,sbyte*,int) |
| 6 | %h = constant [2 x sbyte] c"h\00" |
| 7 | %hel = constant [4 x sbyte] c"hel\00" |
| 8 | %hello_u = constant [8 x sbyte] c"hello_u\00" |
| 9 | |
| 10 | implementation |
| 11 | |
| 12 | void %test(sbyte *%P, sbyte *%Q, int %N, int* %IP, bool *%BP) { |
| 13 | %A = call int %memcmp(sbyte *%P, sbyte* %P, int %N) |
| 14 | volatile store int %A, int* %IP |
| 15 | %B = call int %memcmp(sbyte *%P, sbyte* %Q, int 0) |
| 16 | volatile store int %B, int* %IP |
| 17 | %C = call int %memcmp(sbyte *%P, sbyte* %Q, int 1) |
| 18 | volatile store int %C, int* %IP |
| 19 | %D = call int %memcmp(sbyte *%P, sbyte* %Q, int 2) |
| 20 | %E = seteq int %D, 0 |
| 21 | volatile store bool %E, bool* %BP |
| 22 | ret void |
| 23 | } |