blob: 8e5962a10a4ff0b34502575c204d268d7ecdaaba [file] [log] [blame]
Reid Spencer8fe86dd2005-04-26 05:22:38 +00001; Test that the StrCatOptimizer works correctly
2; RUN: llvm-as < %s | opt -simplify-libcalls | llvm-dis | not grep 'call.*strlen'
3
Reid Spencerc662bc72005-04-26 19:04:46 +00004declare uint %strlen(sbyte*)
Reid Spencerabffafd2005-04-30 03:06:36 +00005%hello = constant [6 x sbyte] c"hello\00"
6%null = constant [1 x sbyte] c"\00"
Reid Spencer8fe86dd2005-04-26 05:22:38 +00007%null_hello = constant [7 x sbyte] c"\00hello\00"
8
9implementation ; Functions:
10
Reid Spencer29a5bf52005-05-07 20:21:04 +000011uint %test1() {
Reid Spencerabffafd2005-04-30 03:06:36 +000012 %hello_p = getelementptr [6 x sbyte]* %hello, int 0, int 0
Reid Spencerabffafd2005-04-30 03:06:36 +000013 %hello_l = call uint %strlen(sbyte* %hello_p)
Reid Spencer29a5bf52005-05-07 20:21:04 +000014 ret uint %hello_l
15}
16
17uint %test2() {
18 %null_p = getelementptr [1 x sbyte]* %null, int 0, int 0
Reid Spencerabffafd2005-04-30 03:06:36 +000019 %null_l = call uint %strlen(sbyte* %null_p)
Reid Spencer29a5bf52005-05-07 20:21:04 +000020 ret uint %null_l
21}
22
23uint %test3() {
24 %null_hello_p = getelementptr [7 x sbyte]* %null_hello, int 0, int 0
Reid Spencerc662bc72005-04-26 19:04:46 +000025 %null_hello_l = call uint %strlen(sbyte* %null_hello_p)
Reid Spencer29a5bf52005-05-07 20:21:04 +000026 ret uint %null_hello_l
27}
28
29bool %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
36bool %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
43bool %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
50bool %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
Reid Spencer8fe86dd2005-04-26 05:22:38 +000055}