Skip to content

Commit 8fab8b1

Browse files
fixup! convert lambda to static func
1 parent a058ee5 commit 8fab8b1

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,48 +1014,48 @@ RISCVCC::CondCode RISCVCC::getOppositeBranchCondition(RISCVCC::CondCode CC) {
10141014
}
10151015
}
10161016

1017-
bool RISCVInstrInfo::trySimplifyCondBr(
1018-
MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB,
1019-
SmallVectorImpl<MachineOperand> &Cond) const {
1017+
// Return true if MO definitely contains the value one.
1018+
static bool isOne(MachineOperand &MO) {
1019+
if (MO.isImm() && MO.getImm() == 1)
1020+
return true;
10201021

1021-
if (!TBB || Cond.size() != 3)
1022+
if (!MO.isReg() || !MO.getReg().isVirtual())
10221023
return false;
10231024

1024-
RISCVCC::CondCode CC = static_cast<RISCVCC::CondCode>(Cond[0].getImm());
1025-
auto LHS = Cond[1];
1026-
auto RHS = Cond[2];
1025+
MachineRegisterInfo &MRI =
1026+
MO.getParent()->getParent()->getParent()->getRegInfo();
1027+
MachineInstr *DefMI = MRI.getUniqueVRegDef(MO.getReg());
1028+
if (!DefMI)
1029+
return false;
10271030

1028-
// Return true if MO definitely contains the value one.
1029-
auto isOne = [](MachineOperand &MO) -> bool {
1030-
if (MO.isImm() && MO.getImm() == 1)
1031-
return true;
1031+
// For now, just check the canonical one value.
1032+
if (DefMI->getOpcode() == RISCV::ADDI &&
1033+
DefMI->getOperand(1).getReg() == RISCV::X0 &&
1034+
DefMI->getOperand(2).getImm() == 1)
1035+
return true;
10321036

1033-
if (!MO.isReg() || !MO.getReg().isVirtual())
1034-
return false;
1037+
return false;
1038+
}
10351039

1036-
MachineRegisterInfo &MRI =
1037-
MO.getParent()->getParent()->getParent()->getRegInfo();
1038-
MachineInstr *DefMI = MRI.getUniqueVRegDef(MO.getReg());
1039-
if (!DefMI)
1040-
return false;
1040+
// Return true if MO definitely contains the value zero.
1041+
static bool isZero(MachineOperand &MO) {
1042+
if (MO.isImm() && MO.getImm() == 0)
1043+
return true;
1044+
if (MO.isReg() && MO.getReg() == RISCV::X0)
1045+
return true;
1046+
return false;
1047+
}
10411048

1042-
// For now, just check the canonical one value.
1043-
if (DefMI->getOpcode() == RISCV::ADDI &&
1044-
DefMI->getOperand(1).getReg() == RISCV::X0 &&
1045-
DefMI->getOperand(2).getImm() == 1)
1046-
return true;
1049+
bool RISCVInstrInfo::trySimplifyCondBr(
1050+
MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB,
1051+
SmallVectorImpl<MachineOperand> &Cond) const {
10471052

1053+
if (!TBB || Cond.size() != 3)
10481054
return false;
1049-
};
10501055

1051-
// Return true if MO definitely contains the value zero.
1052-
auto isZero = [](MachineOperand &MO) -> bool {
1053-
if (MO.isImm() && MO.getImm() == 0)
1054-
return true;
1055-
if (MO.isReg() && MO.getReg() == RISCV::X0)
1056-
return true;
1057-
return false;
1058-
};
1056+
RISCVCC::CondCode CC = static_cast<RISCVCC::CondCode>(Cond[0].getImm());
1057+
auto LHS = Cond[1];
1058+
auto RHS = Cond[2];
10591059

10601060
MachineBasicBlock *Folded = nullptr;
10611061
switch (CC) {

0 commit comments

Comments
 (0)