[llvm] [RISCV][VLOPT] Add support for checkUsers when UserMI is a Single-Width Integer Reduction (PR #120345)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 08:46:19 PST 2025


================
@@ -901,11 +918,29 @@ bool RISCVVLOptimizer::checkUsers(const MachineOperand *&CommonVL,
 
     // Instructions like reductions may use a vector register as a scalar
     // register. In this case, we should treat it like a scalar register which
-    // does not impact the decision on whether to optimize VL.
-    // TODO: Treat it like a scalar register instead of bailing out.
+    // does not impact the decision on whether to optimize VL. But if there is
+    // another user of MI and it has VL=0, we need to be sure not to reduce the
+    // VL of MI to zero when the VLOp of UserOp is may be non-zero.
----------------
lukel97 wrote:

```suggestion
    // VL of MI to zero when the VLOp of UserOp may be non-zero.
```

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


More information about the llvm-commits mailing list