Skip to content

Commit 44feae8

Browse files
committed
[RISCV][VLOPT] Mark some methods + arguments as const. NFC
1 parent 55fa2fa commit 44feae8

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ class RISCVVLOptimizer : public MachineFunctionPass {
5050
StringRef getPassName() const override { return PASS_NAME; }
5151

5252
private:
53-
std::optional<MachineOperand> getMinimumVLForUser(MachineOperand &UserOp);
53+
std::optional<MachineOperand>
54+
getMinimumVLForUser(const MachineOperand &UserOp) const;
5455
/// Returns the largest common VL MachineOperand that may be used to optimize
5556
/// 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;
5859
bool isCandidate(const MachineInstr &MI) const;
5960

6061
/// For a given instruction, records what elements of it are demanded by
@@ -1152,8 +1153,8 @@ static bool isSupportedInstr(const MachineInstr &MI) {
11521153
}
11531154

11541155
/// 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();
11571158
const RISCVVPseudosTable::PseudoInfo *RVV =
11581159
RISCVVPseudosTable::getPseudoInfo(MI->getOpcode());
11591160

@@ -1261,7 +1262,7 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const {
12611262
}
12621263

12631264
std::optional<MachineOperand>
1264-
RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
1265+
RISCVVLOptimizer::getMinimumVLForUser(const MachineOperand &UserOp) const {
12651266
const MachineInstr &UserMI = *UserOp.getParent();
12661267
const MCInstrDesc &Desc = UserMI.getDesc();
12671268

@@ -1282,7 +1283,7 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
12821283
if (UserOp.isTied()) {
12831284
assert(UserOp.getOperandNo() == UserMI.getNumExplicitDefs() &&
12841285
RISCVII::isFirstDefTiedToFirstUse(UserMI.getDesc()));
1285-
auto DemandedVL = DemandedVLs[&UserMI];
1286+
auto DemandedVL = DemandedVLs.lookup(&UserMI);
12861287
if (!DemandedVL || !RISCV::isVLKnownLE(*DemandedVL, VLOp)) {
12871288
LLVM_DEBUG(dbgs() << " Abort because user is passthru in "
12881289
"instruction with demanded tail\n");
@@ -1304,7 +1305,7 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
13041305

13051306
// If we know the demanded VL of UserMI, then we can reduce the VL it
13061307
// requires.
1307-
if (auto DemandedVL = DemandedVLs[&UserMI]) {
1308+
if (auto DemandedVL = DemandedVLs.lookup(&UserMI)) {
13081309
assert(isCandidate(UserMI));
13091310
if (RISCV::isVLKnownLE(*DemandedVL, VLOp))
13101311
return DemandedVL;
@@ -1313,7 +1314,8 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
13131314
return VLOp;
13141315
}
13151316

1316-
std::optional<MachineOperand> RISCVVLOptimizer::checkUsers(MachineInstr &MI) {
1317+
std::optional<MachineOperand>
1318+
RISCVVLOptimizer::checkUsers(const MachineInstr &MI) const {
13171319
std::optional<MachineOperand> CommonVL;
13181320
SmallSetVector<MachineOperand *, 8> Worklist;
13191321
for (auto &UserOp : MRI->use_operands(MI.getOperand(0).getReg()))
@@ -1386,7 +1388,7 @@ std::optional<MachineOperand> RISCVVLOptimizer::checkUsers(MachineInstr &MI) {
13861388
return CommonVL;
13871389
}
13881390

1389-
bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) {
1391+
bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) const {
13901392
LLVM_DEBUG(dbgs() << "Trying to reduce VL for " << MI << "\n");
13911393

13921394
unsigned VLOpNum = RISCVII::getVLOpNum(MI.getDesc());
@@ -1399,7 +1401,7 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) {
13991401
return false;
14001402
}
14011403

1402-
auto CommonVL = DemandedVLs[&MI];
1404+
auto CommonVL = DemandedVLs.lookup(&MI);
14031405
if (!CommonVL)
14041406
return false;
14051407

0 commit comments

Comments
 (0)