[backend]微优化与可读性维护不影响原逻辑和分数
This commit is contained in:
@@ -398,13 +398,15 @@ void RISCv64RegAlloc::getInstrUseDef(MachineInstr* instr, LiveSet& use, LiveSet&
|
||||
}
|
||||
} else { // [修复] CALL指令也可能定义物理寄存器(如a0)
|
||||
if (first_reg_operand_is_def) {
|
||||
if (preg_to_vreg_id_map.count(reg_op->getPReg())) {
|
||||
def.insert(preg_to_vreg_id_map.at(reg_op->getPReg()));
|
||||
}
|
||||
auto it = preg_to_vreg_id_map.find(reg_op->getPReg());
|
||||
if (it != preg_to_vreg_id_map.end()) {
|
||||
def.insert(it->second);
|
||||
}
|
||||
first_reg_operand_is_def = false;
|
||||
} else {
|
||||
if (preg_to_vreg_id_map.count(reg_op->getPReg())) {
|
||||
use.insert(preg_to_vreg_id_map.at(reg_op->getPReg()));
|
||||
auto it = preg_to_vreg_id_map.find(reg_op->getPReg());
|
||||
if (it != preg_to_vreg_id_map.end()) {
|
||||
use.insert(it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -444,9 +446,10 @@ void RISCv64RegAlloc::getInstrUseDef(MachineInstr* instr, LiveSet& use, LiveSet&
|
||||
if (reg_op->isVirtual()) {
|
||||
def.insert(reg_op->getVRegNum());
|
||||
} else { // 物理寄存器也可以是 Def
|
||||
if (preg_to_vreg_id_map.count(reg_op->getPReg())) {
|
||||
def.insert(preg_to_vreg_id_map.at(reg_op->getPReg()));
|
||||
}
|
||||
auto it = preg_to_vreg_id_map.find(reg_op->getPReg());
|
||||
if (it != preg_to_vreg_id_map.end()) {
|
||||
def.insert(it->second);
|
||||
}
|
||||
}
|
||||
first_reg_is_def = false; // **关键**:处理完第一个寄存器后,立即更新标志
|
||||
} else {
|
||||
@@ -454,8 +457,9 @@ void RISCv64RegAlloc::getInstrUseDef(MachineInstr* instr, LiveSet& use, LiveSet&
|
||||
if (reg_op->isVirtual()) {
|
||||
use.insert(reg_op->getVRegNum());
|
||||
} else { // 物理寄存器也可以是 Use
|
||||
if (preg_to_vreg_id_map.count(reg_op->getPReg())) {
|
||||
use.insert(preg_to_vreg_id_map.at(reg_op->getPReg()));
|
||||
auto it = preg_to_vreg_id_map.find(reg_op->getPReg());
|
||||
if (it != preg_to_vreg_id_map.end()) {
|
||||
use.insert(it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -467,8 +471,9 @@ void RISCv64RegAlloc::getInstrUseDef(MachineInstr* instr, LiveSet& use, LiveSet&
|
||||
use.insert(base_reg->getVRegNum());
|
||||
} else {
|
||||
PhysicalReg preg = base_reg->getPReg();
|
||||
if (preg_to_vreg_id_map.count(preg)) {
|
||||
use.insert(preg_to_vreg_id_map.at(preg));
|
||||
auto it = preg_to_vreg_id_map.find(preg);
|
||||
if (it != preg_to_vreg_id_map.end()) {
|
||||
use.insert(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,8 +485,9 @@ void RISCv64RegAlloc::getInstrUseDef(MachineInstr* instr, LiveSet& use, LiveSet&
|
||||
if (src_reg_op->isVirtual()) {
|
||||
use.insert(src_reg_op->getVRegNum());
|
||||
} else {
|
||||
if (preg_to_vreg_id_map.count(src_reg_op->getPReg())) {
|
||||
use.insert(preg_to_vreg_id_map.at(src_reg_op->getPReg()));
|
||||
auto it = preg_to_vreg_id_map.find(src_reg_op->getPReg());
|
||||
if (it != preg_to_vreg_id_map.end()) {
|
||||
use.insert(it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user