Skip to content

Commit a6c215c

Browse files
committed
Reuse isLoadImm, assert MRI is in SSA
1 parent 8072205 commit a6c215c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4801,16 +4801,17 @@ static std::optional<int64_t> getEffectiveImm(const MachineOperand &MO,
48014801
assert(MO.isImm() || MO.getReg().isVirtual());
48024802
if (MO.isImm())
48034803
return MO.getImm();
4804-
MachineInstr *Def = MRI->getVRegDef(MO.getReg());
4805-
if (Def->getOpcode() == RISCV::ADDI &&
4806-
Def->getOperand(1).getReg() == RISCV::X0)
4807-
return Def->getOperand(2).getImm();
4804+
const MachineInstr *Def = MRI->getVRegDef(MO.getReg());
4805+
int64_t Imm;
4806+
if (isLoadImm(Def, Imm))
4807+
return Imm;
48084808
return std::nullopt;
48094809
}
48104810

4811-
/// Given two VL operands, do we know that LHS <= RHS?
4811+
/// Given two VL operands, do we know that LHS <= RHS? Must be used in SSA form.
48124812
bool RISCV::isVLKnownLE(const MachineOperand &LHS, const MachineOperand &RHS,
48134813
const MachineRegisterInfo *MRI) {
4814+
assert(MRI->isSSA());
48144815
if (LHS.isReg() && RHS.isReg() && LHS.getReg().isVirtual() &&
48154816
LHS.getReg() == RHS.getReg())
48164817
return true;

0 commit comments

Comments
 (0)