Skip to content

Commit 55b5ac8

Browse files
authored
[RISCV] Remove X0 handling from RISCVInstrInfo::optimizeCondBranch. (#81931)
This was trying to rewrite a branch that uses X0 to a branch that uses a register produced by LI of 1 or -1. Using X0 is free so there is no reason to rewrite it. Doing so would just extend the live range of the LI register increasing register pressure. In practice this might not have triggered often because we were calling MRI.hasOneUse on X0. I'm not sure what the returns for a physical reigster.
1 parent 088c7ce commit 55b5ac8

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,13 +1211,7 @@ bool RISCVInstrInfo::optimizeCondBranch(MachineInstr &MI) const {
12111211
if (!Op.isReg())
12121212
return false;
12131213
Register Reg = Op.getReg();
1214-
if (Reg == RISCV::X0) {
1215-
Imm = 0;
1216-
return true;
1217-
}
1218-
if (!Reg.isVirtual())
1219-
return false;
1220-
return isLoadImm(MRI.getVRegDef(Op.getReg()), Imm);
1214+
return Reg.isVirtual() && isLoadImm(MRI.getVRegDef(Reg), Imm);
12211215
};
12221216

12231217
MachineOperand &LHS = MI.getOperand(0);

0 commit comments

Comments
 (0)