1 ; Test that the StrCatOptimizer works correctly
2 ; RUN: opt < %s -simplify-libcalls -S | \
3 ; RUN: not grep {call.*strlen}
5 target datalayout = "e-p:32:32"
6 @hello = constant [6 x i8] c"hello\00" ; <[6 x i8]*> [#uses=3]
7 @null = constant [1 x i8] zeroinitializer ; <[1 x i8]*> [#uses=3]
8 @null_hello = constant [7 x i8] c"\00hello\00" ; <[7 x i8]*> [#uses=1]
10 declare i32 @strlen(i8*)
13 %hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
14 %hello_l = call i32 @strlen( i8* %hello_p ) ; <i32> [#uses=1]
19 %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
20 %null_l = call i32 @strlen( i8* %null_p ) ; <i32> [#uses=1]
25 %null_hello_p = getelementptr [7 x i8]* @null_hello, i32 0, i32 0 ; <i8*> [#uses=1]
26 %null_hello_l = call i32 @strlen( i8* %null_hello_p ) ; <i32> [#uses=1]
31 %hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
32 %hello_l = call i32 @strlen( i8* %hello_p ) ; <i32> [#uses=1]
33 %eq_hello = icmp eq i32 %hello_l, 0 ; <i1> [#uses=1]
38 %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
39 %null_l = call i32 @strlen( i8* %null_p ) ; <i32> [#uses=1]
40 %eq_null = icmp eq i32 %null_l, 0 ; <i1> [#uses=1]
45 %hello_p = getelementptr [6 x i8]* @hello, i32 0, i32 0 ; <i8*> [#uses=1]
46 %hello_l = call i32 @strlen( i8* %hello_p ) ; <i32> [#uses=1]
47 %ne_hello = icmp ne i32 %hello_l, 0 ; <i1> [#uses=1]
52 %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0 ; <i8*> [#uses=1]
53 %null_l = call i32 @strlen( i8* %null_p ) ; <i32> [#uses=1]
54 %ne_null = icmp ne i32 %null_l, 0 ; <i1> [#uses=1]