llvm.org GIT mirror llvm / 81cccc9
Code size optimisation: do not inline memcpy if this expansion results in more instructions than the libary call. Differential Revision: http://reviews.llvm.org/D20958 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271678 91177308-0d34-0410-b5e6-96231b3b80d8 Sjoerd Meijer 4 years ago
2 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
175175 // emit.
176176 unsigned NumMEMCPYs = (NumMemOps + MaxLoadsInLDM - 1) / MaxLoadsInLDM;
177177
178 // Code size optimisation: do not inline memcpy if expansion results in
179 // more instructions than the libary call.
180 if (NumMEMCPYs > 1 && DAG.getMachineFunction().getFunction()->optForMinSize()) {
181 return SDValue();
182 }
183
178184 SDVTList VTs = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other, MVT::Glue);
179185
180186 for (unsigned I = 0; I != NumMEMCPYs; ++I) {
0 ; RUN: llc -mtriple=thumbv7m-arm-none-eabi -mcpu=cortex-m3 < %s | FileCheck %s
1
2 %struct.mystruct = type { [31 x i8] }
3
4 @.str = private unnamed_addr constant [31 x i8] c"012345678901234567890123456789\00", align 1
5 @.str.1 = private unnamed_addr constant [21 x i8] c"01234567890123456789\00", align 1
6
7 @myglobal = common global %struct.mystruct zeroinitializer, align 1
8
9 define void @foo() #0 {
10 entry:
11 ; CHECK-LABEL: foo:
12 ; CHECK: __aeabi_memcpy
13 ; CHECK-NOT: ldm
14 %mystring = alloca [31 x i8], align 1
15 %0 = getelementptr inbounds [31 x i8], [31 x i8]* %mystring, i32 0, i32 0
16 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i32 0, i32 0), i32 31, i32 1, i1 false)
17 ret void
18 }
19
20 define void @bar() #0 {
21 entry:
22 ; CHECK-LABEL: bar:
23 ; CHECK-NOT: __aeabi_memcpy
24 %mystring = alloca [31 x i8], align 1
25 %0 = getelementptr inbounds [31 x i8], [31 x i8]* %mystring, i32 0, i32 0
26 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i32 0, i32 0), i32 21, i32 1, i1 false)
27 ret void
28 }
29
30 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #1
31
32 attributes #0 = { minsize noinline nounwind optsize }