blob: bea9eed74a569cbc2e0978c5770ca0c018c1f007 [file] [log] [blame]
Chris Lattner475cfe42005-09-29 06:11:34 +00001; Test that the memcmpOptimizer works correctly
Reid Spencer43b40032007-04-16 15:31:49 +00002; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | \
3; RUN: not grep {call.*memcmp}
Reid Spencer69ccadd2006-12-02 04:23:10 +00004; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls -disable-output
Chris Lattner475cfe42005-09-29 06:11:34 +00005
6declare 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
11implementation
12
13void %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}