@@ -114,14 +114,6 @@ FunctionPass *llvm::createRISCVVLOptimizerPass() {
114114 return new RISCVVLOptimizer ();
115115}
116116
117- // / Return true if R is a physical or virtual vector register, false otherwise.
118- static bool isVectorRegClass (Register R, const MachineRegisterInfo *MRI) {
119- if (R.isPhysical ())
120- return RISCV::VRRegClass.contains (R);
121- const TargetRegisterClass *RC = MRI->getRegClass (R);
122- return RISCVRI::isVRegClass (RC->TSFlags );
123- }
124-
125117LLVM_ATTRIBUTE_UNUSED
126118static raw_ostream &operator <<(raw_ostream &OS, const OperandInfo &OI) {
127119 OI.print (OS);
@@ -183,37 +175,28 @@ static unsigned getIntegerExtensionOperandEEW(unsigned Factor,
183175 return Log2EEW;
184176}
185177
186- // / Check whether MO is a mask operand of MI.
187- static bool isMaskOperand (const MachineInstr &MI, const MachineOperand &MO,
188- const MachineRegisterInfo *MRI) {
189-
190- if (!MO.isReg () || !isVectorRegClass (MO.getReg (), MRI))
191- return false ;
192-
193- const MCInstrDesc &Desc = MI.getDesc ();
194- return Desc.operands ()[MO.getOperandNo ()].RegClass == RISCV::VMV0RegClassID;
195- }
196-
197178static std::optional<unsigned >
198179getOperandLog2EEW (const MachineOperand &MO, const MachineRegisterInfo *MRI) {
199180 const MachineInstr &MI = *MO.getParent ();
181+ const MCInstrDesc &Desc = MI.getDesc ();
200182 const RISCVVPseudosTable::PseudoInfo *RVV =
201183 RISCVVPseudosTable::getPseudoInfo (MI.getOpcode ());
202184 assert (RVV && " Could not find MI in PseudoTable" );
203185
204186 // MI has a SEW associated with it. The RVV specification defines
205187 // the EEW of each operand and definition in relation to MI.SEW.
206- unsigned MILog2SEW =
207- MI.getOperand (RISCVII::getSEWOpNum (MI.getDesc ())).getImm ();
188+ unsigned MILog2SEW = MI.getOperand (RISCVII::getSEWOpNum (Desc)).getImm ();
208189
209- const bool HasPassthru = RISCVII::isFirstDefTiedToFirstUse (MI. getDesc () );
210- const bool IsTied = RISCVII::isTiedPseudo (MI. getDesc () .TSFlags );
190+ const bool HasPassthru = RISCVII::isFirstDefTiedToFirstUse (Desc );
191+ const bool IsTied = RISCVII::isTiedPseudo (Desc .TSFlags );
211192
212193 bool IsMODef = MO.getOperandNo () == 0 ||
213194 (HasPassthru && MO.getOperandNo () == MI.getNumExplicitDefs ());
214195
215196 // All mask operands have EEW=1
216- if (isMaskOperand (MI, MO, MRI))
197+ const MCOperandInfo &Info = Desc.operands ()[MO.getOperandNo ()];
198+ if (Info.OperandType == MCOI::OPERAND_REGISTER &&
199+ Info.RegClass == RISCV::VMV0RegClassID)
217200 return 0 ;
218201
219202 // switch against BaseInstr to reduce number of cases that need to be
@@ -1296,8 +1279,8 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const {
12961279 TII->get (RISCV::getRVVMCOpcode (MI.getOpcode ())).TSFlags ) &&
12971280 " Instruction shouldn't be supported if elements depend on VL" );
12981281
1299- assert (MI. getOperand ( 0 ). isReg () &&
1300- isVectorRegClass (MI.getOperand (0 ).getReg (), MRI ) &&
1282+ assert (RISCVRI::isVRegClass (
1283+ MRI-> getRegClass (MI.getOperand (0 ).getReg ())-> TSFlags ) &&
13011284 " All supported instructions produce a vector register result" );
13021285
13031286 LLVM_DEBUG (dbgs () << " Found a candidate for VL reduction: " << MI << " \n " );
0 commit comments