xref: /llvm-project/llvm/test/Transforms/InstCombine/ARM/strcpy.ll (revision fcfc31fffb9a83416453e60bd0dff2df93c2ee20)
1; Test that the strcpy library call simplifier works correctly for ARM procedure calls
2; RUN: opt < %s -passes=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 ptr @strcpy(ptr, ptr)
13
14define arm_aapcscc void @test_simplify1() {
15; CHECK-LABEL: @test_simplify1(
16
17
18  call arm_aapcscc ptr @strcpy(ptr @a, ptr @hello)
19; CHECK: @llvm.memcpy.p0.p0.i32
20  ret void
21}
22
23define arm_aapcscc ptr @test_simplify2() {
24; CHECK-LABEL: @test_simplify2(
25
26
27  %ret = call arm_aapcscc ptr @strcpy(ptr @a, ptr @a)
28; CHECK: ret ptr @a
29  ret ptr %ret
30}
31
32define arm_aapcscc ptr @test_no_simplify1() {
33; CHECK-LABEL: @test_no_simplify1(
34
35
36  %ret = call arm_aapcscc ptr @strcpy(ptr @a, ptr @b)
37; CHECK: call arm_aapcscc ptr @strcpy
38  ret ptr %ret
39}
40
41define arm_aapcs_vfpcc void @test_simplify1_vfp() {
42; CHECK-LABEL: @test_simplify1_vfp(
43
44
45  call arm_aapcs_vfpcc ptr @strcpy(ptr @a, ptr @hello)
46; CHECK: @llvm.memcpy.p0.p0.i32
47  ret void
48}
49
50define arm_aapcs_vfpcc ptr @test_simplify2_vfp() {
51; CHECK-LABEL: @test_simplify2_vfp(
52
53
54  %ret = call arm_aapcs_vfpcc ptr @strcpy(ptr @a, ptr @a)
55; CHECK: ret ptr @a
56  ret ptr %ret
57}
58
59define arm_aapcs_vfpcc ptr @test_no_simplify1_vfp() {
60; CHECK-LABEL: @test_no_simplify1_vfp(
61
62
63  %ret = call arm_aapcs_vfpcc ptr @strcpy(ptr @a, ptr @b)
64; CHECK: call arm_aapcs_vfpcc ptr @strcpy
65  ret ptr %ret
66}
67