* Add a test case for StrLenOptimization
[oota-llvm.git] / test / Transforms / SimplifyLibCalls / StrLen.ll
1 ; Test that the StrCatOptimizer works correctly
2 ; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*strlen'
3
4 declare int %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 int %main () {
12   %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
13   %hello_l = call int %strlen(sbyte* %hello_p)
14   %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
15   %null_l = call int %strlen(sbyte* %null_p)
16   %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
17   %null_hello_l = call int %strlen(sbyte* %null_hello_p)
18   %sum1 = add int %hello_l, %null_l
19   %sum2 = add int %sum1, %null_hello_l
20   ret int %sum2
21 }