Skip to content

Commit 8704e55

Browse files
committed
[RISCV] Remove unneeded plumbing of MRI in VLOptimizer. NFC
getOperandInfo and getOperandLog2EEW don't use MRI anymore, and isTupleInsertInstr can fetch MRI from the MachineOperand itself.
1 parent 633233c commit 8704e55

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ static unsigned getIntegerExtensionOperandEEW(unsigned Factor,
191191
#define VSUXSEG_CASES(EEW) VSEG_CASES(VSUX, I##EEW)
192192
#define VSOXSEG_CASES(EEW) VSEG_CASES(VSOX, I##EEW)
193193

194-
static std::optional<unsigned>
195-
getOperandLog2EEW(const MachineOperand &MO, const MachineRegisterInfo *MRI) {
194+
static std::optional<unsigned> getOperandLog2EEW(const MachineOperand &MO) {
196195
const MachineInstr &MI = *MO.getParent();
197196
const MCInstrDesc &Desc = MI.getDesc();
198197
const RISCVVPseudosTable::PseudoInfo *RVV =
@@ -810,14 +809,13 @@ getOperandLog2EEW(const MachineOperand &MO, const MachineRegisterInfo *MRI) {
810809
}
811810
}
812811

813-
static std::optional<OperandInfo>
814-
getOperandInfo(const MachineOperand &MO, const MachineRegisterInfo *MRI) {
812+
static std::optional<OperandInfo> getOperandInfo(const MachineOperand &MO) {
815813
const MachineInstr &MI = *MO.getParent();
816814
const RISCVVPseudosTable::PseudoInfo *RVV =
817815
RISCVVPseudosTable::getPseudoInfo(MI.getOpcode());
818816
assert(RVV && "Could not find MI in PseudoTable");
819817

820-
std::optional<unsigned> Log2EEW = getOperandLog2EEW(MO, MRI);
818+
std::optional<unsigned> Log2EEW = getOperandLog2EEW(MO);
821819
if (!Log2EEW)
822820
return std::nullopt;
823821

@@ -1407,11 +1405,11 @@ RISCVVLOptimizer::getMinimumVLForUser(const MachineOperand &UserOp) const {
14071405
/// Return true if MI is an instruction used for assembling registers
14081406
/// for segmented store instructions, namely, RISCVISD::TUPLE_INSERT.
14091407
/// Currently it's lowered to INSERT_SUBREG.
1410-
static bool isTupleInsertInstr(const MachineInstr &MI,
1411-
const MachineRegisterInfo &MRI) {
1412-
if (MI.getOpcode() != RISCV::INSERT_SUBREG)
1408+
static bool isTupleInsertInstr(const MachineInstr &MI) {
1409+
if (!MI.isInsertSubreg())
14131410
return false;
14141411

1412+
const MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
14151413
const TargetRegisterClass *DstRC = MRI.getRegClass(MI.getOperand(0).getReg());
14161414
const TargetRegisterInfo *TRI = MRI.getTargetRegisterInfo();
14171415
if (!RISCVRI::isVRegClass(DstRC->TSFlags))
@@ -1472,7 +1470,7 @@ RISCVVLOptimizer::checkUsers(const MachineInstr &MI) const {
14721470
continue;
14731471
}
14741472

1475-
if (isTupleInsertInstr(UserMI, *MRI)) {
1473+
if (isTupleInsertInstr(UserMI)) {
14761474
LLVM_DEBUG(dbgs().indent(4) << "Peeking through uses of INSERT_SUBREG\n");
14771475
for (MachineOperand &UseOp :
14781476
MRI->use_operands(UserMI.getOperand(0).getReg())) {
@@ -1481,7 +1479,7 @@ RISCVVLOptimizer::checkUsers(const MachineInstr &MI) const {
14811479
// or another INSERT_SUBREG, since VL just works differently
14821480
// between segmented operations (per-field) v.s. other RVV ops (on the
14831481
// whole register group).
1484-
if (!isTupleInsertInstr(CandidateMI, *MRI) &&
1482+
if (!isTupleInsertInstr(CandidateMI) &&
14851483
!isSegmentedStoreInstr(CandidateMI))
14861484
return std::nullopt;
14871485
Worklist.insert(&UseOp);
@@ -1518,9 +1516,8 @@ RISCVVLOptimizer::checkUsers(const MachineInstr &MI) const {
15181516
return std::nullopt;
15191517
}
15201518

1521-
std::optional<OperandInfo> ConsumerInfo = getOperandInfo(UserOp, MRI);
1522-
std::optional<OperandInfo> ProducerInfo =
1523-
getOperandInfo(MI.getOperand(0), MRI);
1519+
std::optional<OperandInfo> ConsumerInfo = getOperandInfo(UserOp);
1520+
std::optional<OperandInfo> ProducerInfo = getOperandInfo(MI.getOperand(0));
15241521
if (!ConsumerInfo || !ProducerInfo) {
15251522
LLVM_DEBUG(dbgs() << " Abort due to unknown operand information.\n");
15261523
LLVM_DEBUG(dbgs() << " ConsumerInfo is: " << ConsumerInfo << "\n");

0 commit comments

Comments
 (0)