1; Test that the strcpy library call simplifier works correctly for ARM procedure calls
2; RUN: opt < %s -instcombine -S | FileCheck %s
3;
4; This transformation requires the pointer size, as it assumes that size_t is
5; the size of a pointer.
6target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
7
8@hello = constant [6 x i8] c"hello\00"
9@a = common global [32 x i8] zeroinitializer, align 1
10@b = common global [32 x i8] zeroinitializer, align 1
11
12declare i8* @strcpy(i8*, i8*)
13
14define arm_aapcscc void @test_simplify1() {
15; CHECK-LABEL: @test_simplify1(
16
17  %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
18  %src = getelementptr [6 x i8], [6 x i8]* @hello, i32 0, i32 0
19
20  call arm_aapcscc i8* @strcpy(i8* %dst, i8* %src)
21; CHECK: @llvm.memcpy.p0i8.p0i8.i32
22  ret void
23}
24
25define arm_aapcscc i8* @test_simplify2() {
26; CHECK-LABEL: @test_simplify2(
27
28  %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
29
30  %ret = call arm_aapcscc i8* @strcpy(i8* %dst, i8* %dst)
31; CHECK: ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0)
32  ret i8* %ret
33}
34
35define arm_aapcscc i8* @test_no_simplify1() {
36; CHECK-LABEL: @test_no_simplify1(
37
38  %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
39  %src = getelementptr [32 x i8], [32 x i8]* @b, i32 0, i32 0
40
41  %ret = call arm_aapcscc i8* @strcpy(i8* %dst, i8* %src)
42; CHECK: call arm_aapcscc i8* @strcpy
43  ret i8* %ret
44}
45
46define arm_aapcs_vfpcc void @test_simplify1_vfp() {
47; CHECK-LABEL: @test_simplify1_vfp(
48
49  %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
50  %src = getelementptr [6 x i8], [6 x i8]* @hello, i32 0, i32 0
51
52  call arm_aapcs_vfpcc i8* @strcpy(i8* %dst, i8* %src)
53; CHECK: @llvm.memcpy.p0i8.p0i8.i32
54  ret void
55}
56
57define arm_aapcs_vfpcc i8* @test_simplify2_vfp() {
58; CHECK-LABEL: @test_simplify2_vfp(
59
60  %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
61
62  %ret = call arm_aapcs_vfpcc i8* @strcpy(i8* %dst, i8* %dst)
63; CHECK: ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @a, i32 0, i32 0)
64  ret i8* %ret
65}
66
67define arm_aapcs_vfpcc i8* @test_no_simplify1_vfp() {
68; CHECK-LABEL: @test_no_simplify1_vfp(
69
70  %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
71  %src = getelementptr [32 x i8], [32 x i8]* @b, i32 0, i32 0
72
73  %ret = call arm_aapcs_vfpcc i8* @strcpy(i8* %dst, i8* %src)
74; CHECK: call arm_aapcs_vfpcc i8* @strcpy
75  ret i8* %ret
76}
77