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