Use the llvm-upgrade program to upgrade llvm assembly.
[oota-llvm.git] / test / Transforms / SimplifyLibCalls / StrLen.ll
1 ; Test that the StrCatOptimizer works correctly
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | not grep 'call.*strlen'
3
4 declare uint %strlen(sbyte*)
5 %hello      = constant [6 x sbyte] c"hello\00"
6 %null       = constant [1 x sbyte] c"\00"
7 %null_hello = constant [7 x sbyte] c"\00hello\00"
8
9 implementation   ; Functions:
10
11 uint %test1() {
12   %hello_p      = getelementptr [6 x sbyte]* %hello, int 0, int 0
13   %hello_l      = call uint %strlen(sbyte* %hello_p)
14   ret uint %hello_l
15 }
16
17 uint %test2() {
18   %null_p       = getelementptr [1 x sbyte]* %null, int 0, int 0
19   %null_l       = call uint %strlen(sbyte* %null_p)
20   ret uint %null_l
21 }
22
23 uint %test3() {
24   %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
25   %null_hello_l = call uint %strlen(sbyte* %null_hello_p)
26   ret uint %null_hello_l
27 }
28
29 bool %test4() {
30   %hello_p      = getelementptr [6 x sbyte]* %hello, int 0, int 0
31   %hello_l      = call uint %strlen(sbyte* %hello_p)
32   %eq_hello     = seteq uint %hello_l, 0
33   ret bool %eq_hello
34 }
35
36 bool %test5() {
37   %null_p       = getelementptr [1 x sbyte]* %null, int 0, int 0
38   %null_l       = call uint %strlen(sbyte* %null_p)
39   %eq_null      = seteq uint %null_l, 0
40   ret bool %eq_null
41 }
42
43 bool %test6() {
44   %hello_p      = getelementptr [6 x sbyte]* %hello, int 0, int 0
45   %hello_l      = call uint %strlen(sbyte* %hello_p)
46   %ne_hello     = setne uint %hello_l, 0
47   ret bool %ne_hello
48 }
49
50 bool %test7() {
51   %null_p       = getelementptr [1 x sbyte]* %null, int 0, int 0
52   %null_l       = call uint %strlen(sbyte* %null_p)
53   %ne_null      = setne uint %null_l, 0
54   ret bool %ne_null
55 }