[llvm] [RISCV][VLOPT][WIP] Added support for vmv.s.x and vfmv.s.f (PR #149562)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 10:15:15 PDT 2025


================
@@ -7,13 +7,14 @@ define i32 @test(ptr %a, i64 %n)  {
 ; CHECK-LABEL: test:
 ; CHECK:       # %bb.0: # %entry
 ; CHECK-NEXT:    li a3, 0
-; CHECK-NEXT:    vsetvli a2, zero, e32, m1, ta, ma
+; CHECK-NEXT:    vsetivli zero, 1, e32, m1, ta, ma
 ; CHECK-NEXT:    vmv.s.x v8, zero
 ; CHECK-NEXT:  .LBB0_1: # %loop
 ; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
 ; CHECK-NEXT:    vl1re32.v v9, (a0)
 ; CHECK-NEXT:    mv a2, a3
 ; CHECK-NEXT:    addi a1, a1, -1
+; CHECK-NEXT:    vsetvli a3, zero, e32, m1, ta, ma
----------------
preames wrote:

Looking at the code for this example, this looks to be an inloop reduction which should be super rare in practice.  For vadd, we really should be doing an out of loop reduction instead.

One thing that's worth investigating (but not blocking this review) is why for this case the extra vsetvli isn't being PREd into the loop header.  If it was, even in this case the extra toggle would be loop invariant (and I think our backwards walk would kill the toggle anyways.).  

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


More information about the llvm-commits mailing list