[llvm] [RISCV] Use vleff's AVL when output VL doesn't dominate in RISCVVLOptimizer (PR #156618)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 01:47:27 PDT 2025


================
@@ -1464,6 +1464,15 @@ bool RISCVVLOptimizer::tryReduceVL(MachineInstr &MI) const {
   assert((CommonVL->isImm() || CommonVL->getReg().isVirtual()) &&
          "Expected VL to be an Imm or virtual Reg");
 
+  // If the VL is defined by a vleff that doesn't dominate MI, try using the
+  // vleff's AVL. It will be greater than or equal to the output VL.
+  if (CommonVL->isReg()) {
+    const MachineInstr *VLMI = MRI->getVRegDef(CommonVL->getReg());
----------------
wangpc-pp wrote:

(Is it OK to not check the nullptr here?)

https://github.com/llvm/llvm-project/pull/156618


More information about the llvm-commits mailing list