[llvm] [RISCV][VLOPT] Compute demanded VLs up front. NFC (PR #124530)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 08:19:18 PST 2025
================
@@ -1355,52 +1370,33 @@ bool RISCVVLOptimizer::runOnMachineFunction(MachineFunction &MF) {
if (!ST.hasVInstructions())
return false;
- SetVector<MachineInstr *> Worklist;
- auto PushOperands = [this, &Worklist](MachineInstr &MI,
- bool IgnoreSameBlock) {
- for (auto &Op : MI.operands()) {
- if (!Op.isReg() || !Op.isUse() || !Op.getReg().isVirtual() ||
- !isVectorRegClass(Op.getReg(), MRI))
- continue;
-
- MachineInstr *DefMI = MRI->getVRegDef(Op.getReg());
- if (!isCandidate(*DefMI))
- continue;
-
- if (IgnoreSameBlock && DefMI->getParent() == MI.getParent())
- continue;
-
- Worklist.insert(DefMI);
- }
- };
+ TII = ST.getInstrInfo();
- // Do a first pass eagerly rewriting in roughly reverse instruction
- // order, populate the worklist with any instructions we might need to
- // revisit. We avoid adding definitions to the worklist if they're
- // in the same block - we're about to visit them anyways.
bool MadeChange = false;
for (MachineBasicBlock &MBB : MF) {
// Avoid unreachable blocks as they have degenerate dominance
if (!MDT->isReachableFromEntry(&MBB))
continue;
- for (auto &MI : make_range(MBB.rbegin(), MBB.rend())) {
+ // For each instruction that defines a vector, compute what VL its
+ // downstream users demand.
+ for (const auto &MI : reverse(MBB)) {
----------------
preames wrote:
The reverse can probably be landed as it's an unrelated NFC.
https://github.com/llvm/llvm-project/pull/124530
More information about the llvm-commits
mailing list