[llvm] [RISCV] Check VL dominates and potentially move in tryReduceVL (PR #106753)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 10:39:05 PDT 2024
================
@@ -456,6 +460,26 @@ static bool dominates(MachineBasicBlock::const_iterator A,
return &*I == A;
}
+/// If the register in \p MO doesn't dominate \p Src, try to move \p Src so it
+/// does. Returns false if doesn't dominate and we can't move. \p MO must be in
+/// the same basic block as \Src.
+bool RISCVVectorPeephole::ensureDominates(const MachineOperand &MO,
+ MachineInstr &Src) const {
+ assert(MO.getParent()->getParent() == Src.getParent());
+ if (!MO.isReg() || MO.getReg() == RISCV::NoRegister)
+ return true;
+
+ MachineInstr *Def = MRI->getVRegDef(MO.getReg());
+ if (Def->getParent() == Src.getParent() && !dominates(Def, Src)) {
+ if (!isSafeToMove(Src, *Def->getNextNode()))
+ return false;
+ // FIXME: Update V0Defs
----------------
preames wrote:
Other option is to only add instructions which have a mask use to the mapping, then moving source wouldn't need to update the mapping. Would also keep the mapping (much) smaller.
https://github.com/llvm/llvm-project/pull/106753
More information about the llvm-commits
mailing list