@@ -33,7 +33,6 @@ namespace {
33
33
class RISCVVLOptimizer : public MachineFunctionPass {
34
34
const MachineRegisterInfo *MRI;
35
35
const MachineDominatorTree *MDT;
36
- const TargetInstrInfo *TII;
37
36
38
37
public:
39
38
static char ID;
@@ -60,7 +59,7 @@ class RISCVVLOptimizer : public MachineFunctionPass {
60
59
61
60
// / For a given instruction, records what elements of it are demanded by
62
61
// / downstream users.
63
- DenseMap<const MachineInstr *, MachineOperand> DemandedVLs;
62
+ DenseMap<const MachineInstr *, std::optional< MachineOperand> > DemandedVLs;
64
63
};
65
64
66
65
} // end anonymous namespace
@@ -1209,15 +1208,10 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
1209
1208
1210
1209
// If we know the demanded VL of UserMI, then we can reduce the VL it
1211
1210
// requires.
1212
- if (DemandedVLs.contains (&UserMI)) {
1213
- // We can only shrink the VL used if the elementwise result doesn't depend
1214
- // on VL (i.e. not vredsum/viota etc.)
1215
- if (!RISCVII::elementsDependOnVL (
1216
- TII->get (RISCV::getRVVMCOpcode (UserMI.getOpcode ())).TSFlags )) {
1217
- const MachineOperand &DemandedVL = DemandedVLs.at (&UserMI);
1218
- if (RISCV::isVLKnownLE (DemandedVL, VLOp))
1219
- return DemandedVL;
1220
- }
1211
+ if (auto DemandedVL = DemandedVLs[&UserMI]) {
1212
+ assert (isCandidate (UserMI));
1213
+ if (RISCV::isVLKnownLE (*DemandedVL, VLOp))
1214
+ return DemandedVL;
1221
1215
}
1222
1216
1223
1217
return VLOp;
@@ -1348,8 +1342,6 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
1348
1342
if (!ST.hasVInstructions ())
1349
1343
return false ;
1350
1344
1351
- TII = ST.getInstrInfo ();
1352
-
1353
1345
// For each instruction that defines a vector, compute what VL its
1354
1346
// downstream users demand.
1355
1347
for (MachineBasicBlock *MBB : post_order (&MF)) {
0 commit comments