[llvm] [RISCV][VLOPT] Compute demanded VLs up front. NFC (PR #124530)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 08:09:54 PST 2025


================
@@ -1202,15 +1208,14 @@ bool RISCVVLOptimizer::isCandidate(const MachineInstr &MI) const {
   return true;
 }
 
-std::optional<MachineOperand>
-RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
+MachineOperand RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
   const MachineInstr &UserMI = *UserOp.getParent();
   const MCInstrDesc &Desc = UserMI.getDesc();
 
   if (!RISCVII::hasVLOp(Desc.TSFlags) || !RISCVII::hasSEWOp(Desc.TSFlags)) {
     LLVM_DEBUG(dbgs() << "    Abort due to lack of VL, assume that"
                          " use VLMAX\n");
-    return std::nullopt;
+    return MachineOperand::CreateImm(RISCV::VLMaxSentinel);
----------------
michaelmaitland wrote:

Not related to this patch, but I wonder if we should avoid calling this function when a user does not have a VL operand. The debug output says that assume it uses VLMAX, but I wonder if it just doesn't depend on VL and could have been excluded from calculating the demanded VL.

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


More information about the llvm-commits mailing list