[llvm] [RISCV] Remove RISCVVectorPeephole::tryToReduceVL (PR #184297)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 00:07:11 PST 2026


================
@@ -867,8 +867,9 @@ define void @test_dag_loop() {
 ; CHECK-NEXT:    vmseq.vv v0, v12, v8
 ; CHECK-NEXT:    vsetvli zero, zero, e16, m8, ta, ma
 ; CHECK-NEXT:    vmv.v.i v8, 0
-; CHECK-NEXT:    vsetvli zero, zero, e16, m8, tu, mu
+; CHECK-NEXT:    vsetivli zero, 1, e16, m8, tu, mu
 ; CHECK-NEXT:    vle16.v v8, (zero), v0.t
----------------
lukel97 wrote:

This is because the vl optimizer doesn't reduce vls in `tryReduceVL` if the vl is already immediate 1:

```c++
  // If the VL is 1, then there is no need to reduce it. This is an
  // optimization, not needed to preserve correctness.
  if (VLOp.isImm() && VLOp.getImm() == 1) {
    LLVM_DEBUG(dbgs() << "  Abort due to VL == 1, no point in reducing.\n");
    return false;
  }
```

I think this was back when `tryReduceVL` was recursive, but I don't think that's the case anymore after #124530. We can probably remove this restriction in another PR.

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


More information about the llvm-commits mailing list