Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 56e1e61

Browse files
author
Sjoerd Meijer
committed
[ARM] LoadStoreOptimizer: reoder limit
The whole design of generating LDMs/STMs is fragile and unreliable: it depends on rescheduling here in the LoadStoreOptimizer that isn't register pressure aware and regalloc that isn't aware of generating LDMs/STMs. This patch adds a (hidden) option to control the total number of instructions that can be re-ordered. I appreciate this looks only a tiny bit better than a hard-coded constant, but at least it allows more easy experimentation with different values for now. Ideally we calculate this reorder limit based on some heuristics, and take register pressure into account. I might be looking into that next. Differential Revision: https://reviews.llvm.org/D57954 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353678 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 65f398e commit 56e1e61

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/Target/ARM/ARMLoadStoreOptimizer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,11 @@ char ARMPreAllocLoadStoreOpt::ID = 0;
20472047
INITIALIZE_PASS(ARMPreAllocLoadStoreOpt, "arm-prera-ldst-opt",
20482048
ARM_PREALLOC_LOAD_STORE_OPT_NAME, false, false)
20492049

2050+
// Limit the number of instructions to be rescheduled.
2051+
// FIXME: tune this limit, and/or come up with some better heuristics.
2052+
static cl::opt<unsigned> InstReorderLimit("arm-prera-ldst-opt-reorder-limit",
2053+
cl::init(8), cl::Hidden);
2054+
20502055
bool ARMPreAllocLoadStoreOpt::runOnMachineFunction(MachineFunction &Fn) {
20512056
if (AssumeMisalignedLoadStores || skipFunction(Fn.getFunction()))
20522057
return false;
@@ -2222,7 +2227,7 @@ bool ARMPreAllocLoadStoreOpt::RescheduleOps(MachineBasicBlock *MBB,
22222227
}
22232228

22242229
// Don't try to reschedule too many instructions.
2225-
if (NumMove == 8) // FIXME: Tune this limit.
2230+
if (NumMove == InstReorderLimit)
22262231
break;
22272232

22282233
// Found a mergable instruction; save information about it.

test/CodeGen/ARM/prera-ldst-insertpt.mir

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# RUN: llc -run-pass arm-prera-ldst-opt %s -o - | FileCheck %s
2+
# RUN: llc -run-pass arm-prera-ldst-opt -arm-prera-ldst-opt-reorder-limit=3 %s -o - | FileCheck %s
3+
# RUN: llc -run-pass arm-prera-ldst-opt -arm-prera-ldst-opt-reorder-limit=2 %s -o - | FileCheck %s --check-prefix=CHECK-LIMIT
24
--- |
35
target triple = "thumbv7---eabi"
46

@@ -79,12 +81,18 @@ body: |
7981
8082
; Make sure we move the paired stores next to each other, and
8183
; insert them in an appropriate location.
82-
; CHECK: t2STRi12 {{.*}}, 0
84+
; CHECK: t2STRi12 {{.*}}, 0
8385
; CHECK-NEXT: t2STRi12 {{.*}}, 4
8486
; CHECK-NEXT: t2STRi12 {{.*}}, 8
8587
; CHECK-NEXT: t2MUL
8688
; CHECK-NEXT: t2MOVi32imm
8789
90+
; CHECK-LIMIT-LABEL: name: b
91+
; CHECK-LIMIT: t2STRi12 {{.*}}, 0
92+
; CHECK-LIMIT-NEXT: t2STRi12 {{.*}}, 4
93+
; CHECK-LIMIT-NEXT: t2MUL
94+
; CHECK-LIMIT-NEXT: t2STRi12 {{.*}}, 8
95+
8896
%4 : rgpr = t2MUL %1, %1, 14, $noreg
8997
%5 : rgpr = t2MOVi32imm -858993459
9098
%6 : rgpr, %7 : rgpr = t2UMULL killed %3, %5, 14, $noreg

0 commit comments

Comments
 (0)