[llvm] [RISCV][NFC] Simplify the creation of Scheduler (PR #142553)
Pengcheng Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 3 00:31:57 PDT 2025
https://github.com/wangpc-pp created https://github.com/llvm/llvm-project/pull/142553
If `createMachineScheduler`/`createPostMachineScheduler` return a
`nullptr`, then we will call `createSchedLive`/`createSchedPostRA`
anyway.
We can always create the Scheduler first and simplify the following
conditions.
>From 67ab3bcdb83416deb0a81556dc8125f4086a29bd Mon Sep 17 00:00:00 2001
From: Pengcheng Wang <wangpengcheng.pp at bytedance.com>
Date: Tue, 3 Jun 2025 15:27:45 +0800
Subject: [PATCH] [RISCV][NFC] Simplify the creation of Scheduler
If `createMachineScheduler`/`createPostMachineScheduler` return a
`nullptr`, then we will call `createSchedLive`/`createSchedPostRA`
anyway.
We can always create the Scheduler first and simplify the following
conditions.
---
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
index 3e12f2afcdd9d..8a47453cedcd3 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -298,9 +298,8 @@ bool RISCVTargetMachine::isNoopAddrSpaceCast(unsigned SrcAS,
ScheduleDAGInstrs *
RISCVTargetMachine::createMachineScheduler(MachineSchedContext *C) const {
- ScheduleDAGMILive *DAG = nullptr;
+ ScheduleDAGMILive *DAG = createSchedLive(C);
if (EnableMISchedLoadStoreClustering) {
- DAG = createSchedLive(C);
DAG->addMutation(createLoadClusterDAGMutation(
DAG->TII, DAG->TRI, /*ReorderWhileClustering=*/true));
DAG->addMutation(createStoreClusterDAGMutation(
@@ -308,18 +307,16 @@ RISCVTargetMachine::createMachineScheduler(MachineSchedContext *C) const {
}
const RISCVSubtarget &ST = C->MF->getSubtarget<RISCVSubtarget>();
- if (!DisableVectorMaskMutation && ST.hasVInstructions()) {
- DAG = DAG ? DAG : createSchedLive(C);
+ if (!DisableVectorMaskMutation && ST.hasVInstructions())
DAG->addMutation(createRISCVVectorMaskDAGMutation(DAG->TRI));
- }
+
return DAG;
}
ScheduleDAGInstrs *
RISCVTargetMachine::createPostMachineScheduler(MachineSchedContext *C) const {
- ScheduleDAGMI *DAG = nullptr;
+ ScheduleDAGMI *DAG = createSchedPostRA(C);
if (EnablePostMISchedLoadStoreClustering) {
- DAG = createSchedPostRA(C);
DAG->addMutation(createLoadClusterDAGMutation(
DAG->TII, DAG->TRI, /*ReorderWhileClustering=*/true));
DAG->addMutation(createStoreClusterDAGMutation(
More information about the llvm-commits
mailing list