1 ; Test that the strcpy library call simplifier works correctly for ARM procedure calls
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; This transformation requires the pointer size, as it assumes that size_t is
5 ; the size of a pointer.
6 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
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
12 declare i8* @strcpy(i8*, i8*)
14 define arm_aapcscc void @test_simplify1() {
15 ; CHECK-LABEL: @test_simplify1(
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
20 call arm_aapcscc i8* @strcpy(i8* %dst, i8* %src)
21 ; CHECK: @llvm.memcpy.p0i8.p0i8.i32
25 define arm_aapcscc i8* @test_simplify2() {
26 ; CHECK-LABEL: @test_simplify2(
28 %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
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)
35 define arm_aapcscc i8* @test_no_simplify1() {
36 ; CHECK-LABEL: @test_no_simplify1(
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
41 %ret = call arm_aapcscc i8* @strcpy(i8* %dst, i8* %src)
42 ; CHECK: call arm_aapcscc i8* @strcpy
46 define arm_aapcs_vfpcc void @test_simplify1_vfp() {
47 ; CHECK-LABEL: @test_simplify1_vfp(
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
52 call arm_aapcs_vfpcc i8* @strcpy(i8* %dst, i8* %src)
53 ; CHECK: @llvm.memcpy.p0i8.p0i8.i32
57 define arm_aapcs_vfpcc i8* @test_simplify2_vfp() {
58 ; CHECK-LABEL: @test_simplify2_vfp(
60 %dst = getelementptr [32 x i8], [32 x i8]* @a, i32 0, i32 0
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)
67 define arm_aapcs_vfpcc i8* @test_no_simplify1_vfp() {
68 ; CHECK-LABEL: @test_no_simplify1_vfp(
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
73 %ret = call arm_aapcs_vfpcc i8* @strcpy(i8* %dst, i8* %src)
74 ; CHECK: call arm_aapcs_vfpcc i8* @strcpy