llvm.org GIT mirror llvm / 57bb792
[ARM] Mark LEApcrel instructions as isAsCheapAsAMove Doing this means that if an LEApcrel is used in two places we will rematerialize instead of generating two MOVs. This is particularly useful for printfs using the same format string, where we want to generate an address into a register that's going to get corrupted by the call. Differential Revision: https://reviews.llvm.org/D32858 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303054 91177308-0d34-0410-b5e6-96231b3b80d8 John Brawn 3 years ago
5 changed file(s) with 33 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
22212221 let Inst{11-0} = label{11-0};
22222222 }
22232223
2224 let hasSideEffects = 0, isReMaterializable = 1 in
2224 let hasSideEffects = 0, isReMaterializable = 1, isAsCheapAsAMove = 1 in
22252225 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
22262226 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
22272227
14011401 let DecoderMethod = "DecodeThumbAddSpecialReg";
14021402 }
14031403
1404 let hasSideEffects = 0, isReMaterializable = 1 in
1404 let hasSideEffects = 0, isReMaterializable = 1, isAsCheapAsAMove = 1 in
14051405 def tLEApcrel : tPseudoInst<(outs tGPR:$Rd), (ins i32imm:$label, pred:$p),
14061406 2, IIC_iALUi, []>, Sched<[WriteALU]>;
14071407
12261226 let DecoderMethod = "DecodeT2Adr";
12271227 }
12281228
1229 let hasSideEffects = 0, isReMaterializable = 1 in
1229 let hasSideEffects = 0, isReMaterializable = 1, isAsCheapAsAMove = 1 in
12301230 def t2LEApcrel : t2PseudoInst<(outs rGPR:$Rd), (ins i32imm:$label, pred:$p),
12311231 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
12321232 let hasSideEffects = 1 in
0 ; RUN: llc -mtriple=armv7a %s -o - | FileCheck %s
1 ; RUN: llc -mtriple=thumbv7m %s -o - | FileCheck %s
2 ; RUN: llc -mtriple=thumbv6m %s -o - | FileCheck %s
3
4 @str.1 = private unnamed_addr constant [58 x i8] c"+-------------------------------------------------------+\00"
5 @str.2 = private unnamed_addr constant [58 x i8] c"| |\00"
6
7 declare i32 @puts(i8* nocapture readonly)
8
9 ; Check that we rematerialize the adr of str.1 instead of doing one adr and two
10 ; movs.
11
12 ; CHECK: adr r0, [[STR1:.LCPI[0-9]+_[0-9]+]]
13 ; CHECK: bl puts
14 ; CHECK: adr r0, {{.LCPI[0-9]+_[0-9]+}}
15 ; CHECK: bl puts
16 ; CHECK: adr r0, [[STR1]]
17 ; CHECK: b{{l?}} puts
18 define void @fn() {
19 entry:
20 %puts1 = tail call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @str.1, i32 0, i32 0))
21 %puts2 = tail call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @str.2, i32 0, i32 0))
22 %puts3 = tail call i32 @puts(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @str.1, i32 0, i32 0))
23 ret void
24 }
0 ; RUN: llc -mtriple=thumbv7 -o - %s | FileCheck %s
11
2 ; CHECK: [sp, #2120]
2 ; p5 will have been pushed to the stack. Check that it's correctly aligned by
3 ; looking at the offset of the instruction that loads it. Note that this is
4 ; very fragile and this test may need to be updated if we happen to spill more
5 ; or less to the stack.
6 ; CHECK: ldr{{(.w)?}} r{{[0-9]+}}, [sp, #2104]
37
48 %struct.struct_2 = type { [172 x %struct.struct_1] }
59 %struct.struct_1 = type { i32, i32, i32 }