Skip to content

Commit 78e22d5

Browse files
committed
[RISCV] Add load/store clustering in post machine schedule
If post machine schedule is used, previous cluster of load/store which formed in machine schedule may break. In order to solve this, add load/sotre clustering to post machine schedule.
1 parent 29ec071 commit 78e22d5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

llvm/lib/Target/RISCV/RISCVTargetMachine.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ static cl::opt<bool> EnableMISchedLoadClustering(
9999
cl::desc("Enable load clustering in the machine scheduler"),
100100
cl::init(true));
101101

102+
static cl::opt<bool> EnableMISchedStoreClustering(
103+
"riscv-misched-store-clustering", cl::Hidden,
104+
cl::desc("Enable store clustering in the machine scheduler"),
105+
cl::init(true));
106+
102107
static cl::opt<bool> EnableVSETVLIAfterRVVRegAlloc(
103108
"riscv-vsetvl-after-rvv-regalloc", cl::Hidden,
104109
cl::desc("Insert vsetvls after vector register allocation"),
@@ -355,6 +360,22 @@ class RISCVPassConfig : public TargetPassConfig {
355360
return DAG;
356361
}
357362

363+
ScheduleDAGInstrs *
364+
createPostMachineScheduler(MachineSchedContext *C) const override {
365+
ScheduleDAGMI *DAG = nullptr;
366+
if (EnableMISchedLoadClustering) {
367+
DAG = createGenericSchedPostRA(C);
368+
DAG->addMutation(createLoadClusterDAGMutation(
369+
DAG->TII, DAG->TRI, /*ReorderWhileClustering=*/true));
370+
}
371+
if (EnableMISchedStoreClustering) {
372+
DAG = DAG ? DAG : createGenericSchedPostRA(C);
373+
DAG->addMutation(createStoreClusterDAGMutation(
374+
DAG->TII, DAG->TRI, /*ReorderWhileClustering=*/true));
375+
}
376+
return DAG;
377+
}
378+
358379
void addIRPasses() override;
359380
bool addPreISel() override;
360381
void addCodeGenPrepare() override;

0 commit comments

Comments
 (0)