[llvm] [MachinePipeliner] Skip reserved registers when computing register pressure (PR #120694)
Pengcheng Wang via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 00:14:24 PST 2024
https://github.com/wangpc-pp created https://github.com/llvm/llvm-project/pull/120694
We used to skip fixed registers, but fixed registers are not enough
because there are some runtime unusable registers like registers
reserved by `-ffixed-xxx` options.
Here we change to use reserved registers so that the estimated
pressure is more accurate.
>From c9c9ff0b2fc84d47459a5e69e5f89683dc596c49 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng <wangpengcheng.pp at bytedance.com>
Date: Fri, 20 Dec 2024 16:09:31 +0800
Subject: [PATCH] [MachinePipeliner] Skip reserved registers when computing
register pressure
We used to skip fixed registers, but fixed registers are not enough
because there are some runtime unusable registers like registers
reserved by `-ffixed-xxx` options.
Here we change to use reserved registers so that the estimated
pressure is more accurate.
---
llvm/lib/CodeGen/MachinePipeliner.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index d2eb7e72ac6b2a..db12b9c343b6bb 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -1283,9 +1283,9 @@ class HighRegisterPressureDetector {
}
}
- // Return true if Reg is fixed one, for example, stack pointer
- bool isFixedRegister(Register Reg) const {
- return Reg.isPhysical() && TRI->isFixedRegister(MF, Reg.asMCReg());
+ // Return true if Reg is reserved one, for example, stack pointer
+ bool isReservedRegister(Register Reg) const {
+ return Reg.isPhysical() && MRI.isReserved(Reg.asMCReg());
}
bool isDefinedInThisLoop(Register Reg) const {
@@ -1311,7 +1311,7 @@ class HighRegisterPressureDetector {
// because it's used only at the first iteration.
if (MI.isPHI() && Reg != getLoopPhiReg(MI, OrigMBB))
continue;
- if (isFixedRegister(Reg))
+ if (isReservedRegister(Reg))
continue;
if (isDefinedInThisLoop(Reg))
continue;
@@ -1423,7 +1423,7 @@ class HighRegisterPressureDetector {
const auto InsertReg = [this, &CurSetPressure](RegSetTy &RegSet,
Register Reg) {
- if (!Reg.isValid() || isFixedRegister(Reg))
+ if (!Reg.isValid() || isReservedRegister(Reg))
return;
bool Inserted = RegSet.insert(Reg).second;
@@ -1437,7 +1437,7 @@ class HighRegisterPressureDetector {
const auto EraseReg = [this, &CurSetPressure](RegSetTy &RegSet,
Register Reg) {
- if (!Reg.isValid() || isFixedRegister(Reg))
+ if (!Reg.isValid() || isReservedRegister(Reg))
return;
// live-in register
More information about the llvm-commits
mailing list