blob: ba2a4e07298e4ae3833c72d2bfd1b9bc20e2e0e6 [file] [log] [blame]
Reid Spencer926bd0c2005-04-30 00:52:04 +00001; Test that the StrCmpOptimizer 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.*strcmp}
Reid Spencer926bd0c2005-04-30 00:52:04 +00004
5declare int %strcmp(sbyte*,sbyte*)
6declare int %puts(sbyte*)
7%hello = constant [6 x sbyte] c"hello\00"
8%hell = constant [5 x sbyte] c"hell\00"
9%null = constant [1 x sbyte] c"\00"
10
11implementation ; Functions:
12
13int %main () {
14 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
15 %hell_p = getelementptr [5 x sbyte]* %hell, int 0, int 0
16 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
17 %temp1 = call int %strcmp(sbyte* %hello_p, sbyte* %hello_p)
18 %temp2 = call int %strcmp(sbyte* %null_p, sbyte* %null_p)
19 %temp3 = call int %strcmp(sbyte* %hello_p, sbyte* %null_p)
20 %temp4 = call int %strcmp(sbyte* %null_p, sbyte* %hello_p)
21 %temp5 = call int %strcmp(sbyte* %hell_p, sbyte* %hello_p)
22 %rslt1 = add int %temp1, %temp2
23 %rslt2 = add int %rslt1, %temp3
24 %rslt3 = add int %rslt2, %temp4
25 %rslt4 = add int %rslt3, %temp5
26 ret int %rslt4
27}