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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 09:18:39 PST 2025


================
@@ -1230,46 +1233,59 @@ RISCVVLOptimizer::getMinimumVLForUser(MachineOperand &UserOp) {
   // Looking for an immediate or a register VL that isn't X0.
   assert((!VLOp.isReg() || VLOp.getReg() != RISCV::X0) &&
          "Did not expect X0 VL");
+
+  // If we know the demanded VL of UserMI, then we can reduce the VL it
+  // requires.
+  if (DemandedVLs.contains(&UserMI)) {
----------------
lukel97 wrote:

Oops, ignore my comment. When I wrote it I was thinking about my initial version of this patch when I computed the demandedVL for every instruction that defined a vector, not just candidates, which is why I was seeing vcpop.m etc.

In the latest version of the patch we still need might have candidate instructions that have aborted, i.e. returned std::nullopt in checkUsers, and so don't have an entry.

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


More information about the llvm-commits mailing list