@@ -114,14 +114,6 @@ FunctionPass *llvm::createRISCVVLOptimizerPass() {
114
114
return new RISCVVLOptimizer ();
115
115
}
116
116
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
-
125
117
LLVM_ATTRIBUTE_UNUSED
126
118
static raw_ostream &operator <<(raw_ostream &OS, const OperandInfo &OI) {
127
119
OI.print (OS);
@@ -183,37 +175,28 @@ static unsigned getIntegerExtensionOperandEEW(unsigned Factor,
183
175
return Log2EEW;
184
176
}
185
177
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
-
197
178
static std::optional<unsigned >
198
179
getOperandLog2EEW (const MachineOperand &MO, const MachineRegisterInfo *MRI) {
199
180
const MachineInstr &MI = *MO.getParent ();
181
+ const MCInstrDesc &Desc = MI.getDesc ();
200
182
const RISCVVPseudosTable::PseudoInfo *RVV =
201
183
RISCVVPseudosTable::getPseudoInfo (MI.getOpcode ());
202
184
assert (RVV && " Could not find MI in PseudoTable" );
203
185
204
186
// MI has a SEW associated with it. The RVV specification defines
205
187
// 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 ();
208
189
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 );
211
192
212
193
bool IsMODef = MO.getOperandNo () == 0 ||
213
194
(HasPassthru && MO.getOperandNo () == MI.getNumExplicitDefs ());
214
195
215
196
// 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)
217
200
return 0 ;
218
201
219
202
// switch against BaseInstr to reduce number of cases that need to be
@@ -1296,8 +1279,8 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const {
1296
1279
TII->get (RISCV::getRVVMCOpcode (MI.getOpcode ())).TSFlags ) &&
1297
1280
" Instruction shouldn't be supported if elements depend on VL" );
1298
1281
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 ) &&
1301
1284
" All supported instructions produce a vector register result" );
1302
1285
1303
1286
LLVM_DEBUG (dbgs () << " Found a candidate for VL reduction: " << MI << " \n " );
0 commit comments