@@ -50,11 +50,12 @@ class RISCVVLOptimizer : public MachineFunctionPass {
50
50
StringRef getPassName () const override { return PASS_NAME; }
51
51
52
52
private:
53
- std::optional<MachineOperand> getMinimumVLForUser (MachineOperand &UserOp);
53
+ std::optional<MachineOperand>
54
+ getMinimumVLForUser (const MachineOperand &UserOp) const ;
54
55
// / Returns the largest common VL MachineOperand that may be used to optimize
55
56
// / MI. Returns std::nullopt if it failed to find a suitable VL.
56
- std::optional<MachineOperand> checkUsers (MachineInstr &MI);
57
- bool tryReduceVL (MachineInstr &MI);
57
+ std::optional<MachineOperand> checkUsers (const MachineInstr &MI) const ;
58
+ bool tryReduceVL (MachineInstr &MI) const ;
58
59
bool isCandidate (const MachineInstr &MI) const ;
59
60
60
61
// / For a given instruction, records what elements of it are demanded by
@@ -1152,8 +1153,8 @@ static bool isSupportedInstr(const MachineInstr &MI) {
1152
1153
}
1153
1154
1154
1155
// / Return true if MO is a vector operand but is used as a scalar operand.
1155
- static bool isVectorOpUsedAsScalarOp (MachineOperand &MO) {
1156
- MachineInstr *MI = MO.getParent ();
1156
+ static bool isVectorOpUsedAsScalarOp (const MachineOperand &MO) {
1157
+ const MachineInstr *MI = MO.getParent ();
1157
1158
const RISCVVPseudosTable::PseudoInfo *RVV =
1158
1159
RISCVVPseudosTable::getPseudoInfo (MI->getOpcode ());
1159
1160
@@ -1261,7 +1262,7 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const {
1261
1262
}
1262
1263
1263
1264
std::optional<MachineOperand>
1264
- RISCVVLOptimizer::getMinimumVLForUser (MachineOperand &UserOp) {
1265
+ RISCVVLOptimizer::getMinimumVLForUser (const MachineOperand &UserOp) const {
1265
1266
const MachineInstr &UserMI = *UserOp.getParent ();
1266
1267
const MCInstrDesc &Desc = UserMI.getDesc ();
1267
1268
@@ -1282,7 +1283,7 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
1282
1283
if (UserOp.isTied ()) {
1283
1284
assert (UserOp.getOperandNo () == UserMI.getNumExplicitDefs () &&
1284
1285
RISCVII::isFirstDefTiedToFirstUse (UserMI.getDesc ()));
1285
- auto DemandedVL = DemandedVLs[ &UserMI] ;
1286
+ auto DemandedVL = DemandedVLs. lookup ( &UserMI) ;
1286
1287
if (!DemandedVL || !RISCV::isVLKnownLE (*DemandedVL, VLOp)) {
1287
1288
LLVM_DEBUG (dbgs () << " Abort because user is passthru in "
1288
1289
" instruction with demanded tail\n " );
@@ -1304,7 +1305,7 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
1304
1305
1305
1306
// If we know the demanded VL of UserMI, then we can reduce the VL it
1306
1307
// requires.
1307
- if (auto DemandedVL = DemandedVLs[ &UserMI] ) {
1308
+ if (auto DemandedVL = DemandedVLs. lookup ( &UserMI) ) {
1308
1309
assert (isCandidate (UserMI));
1309
1310
if (RISCV::isVLKnownLE (*DemandedVL, VLOp))
1310
1311
return DemandedVL;
@@ -1313,7 +1314,8 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
1313
1314
return VLOp;
1314
1315
}
1315
1316
1316
- std::optional<MachineOperand> RISCVVLOptimizer::checkUsers (MachineInstr &MI) {
1317
+ std::optional<MachineOperand>
1318
+ RISCVVLOptimizer::checkUsers (const MachineInstr &MI) const {
1317
1319
std::optional<MachineOperand> CommonVL;
1318
1320
SmallSetVector<MachineOperand *, 8 > Worklist;
1319
1321
for (auto &UserOp : MRI->use_operands (MI.getOperand (0 ).getReg ()))
@@ -1386,7 +1388,7 @@ std::optional<MachineOperand> RISCVVLOptimizer::checkUsers(MachineInstr &MI) {
1386
1388
return CommonVL;
1387
1389
}
1388
1390
1389
- bool RISCVVLOptimizer::tryReduceVL (MachineInstr &MI) {
1391
+ bool RISCVVLOptimizer::tryReduceVL (MachineInstr &MI) const {
1390
1392
LLVM_DEBUG (dbgs () << " Trying to reduce VL for " << MI << " \n " );
1391
1393
1392
1394
unsigned VLOpNum = RISCVII::getVLOpNum (MI.getDesc ());
@@ -1399,7 +1401,7 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) {
1399
1401
return false ;
1400
1402
}
1401
1403
1402
- auto CommonVL = DemandedVLs[ &MI] ;
1404
+ auto CommonVL = DemandedVLs. lookup ( &MI) ;
1403
1405
if (!CommonVL)
1404
1406
return false ;
1405
1407
0 commit comments