[llvm] [RISCV] Remove hasSideEffects=1 for vsetvli pseudos (PR #91319)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 03:05:51 PDT 2024


================
@@ -102,22 +102,24 @@ declare <vscale x 1 x i1> @llvm.riscv.vmand.nxv1i1.i64(<vscale x 1 x i1>, <vscal
 define void @test6(ptr nocapture readonly %A, ptr nocapture %B, i64 %n) {
 ; CHECK-LABEL: test6:
 ; CHECK:       # %bb.0: # %entry
-; CHECK-NEXT:    vsetvli a6, a2, e32, m1, ta, ma
-; CHECK-NEXT:    beqz a6, .LBB5_3
+; CHECK-NEXT:    vsetvli a3, a2, e32, m1, ta, ma
+; CHECK-NEXT:    beqz a3, .LBB5_3
 ; CHECK-NEXT:  # %bb.1: # %for.body.preheader
 ; CHECK-NEXT:    li a4, 0
+; CHECK-NEXT:    vsetvli a6, a2, e32, m1, ta, ma
 ; CHECK-NEXT:  .LBB5_2: # %for.body
 ; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
-; CHECK-NEXT:    slli a3, a4, 2
-; CHECK-NEXT:    add a5, a0, a3
-; CHECK-NEXT:    vle32.v v8, (a5)
+; CHECK-NEXT:    slli a5, a4, 2
+; CHECK-NEXT:    add a2, a0, a5
+; CHECK-NEXT:    vsetvli zero, a3, e32, m1, ta, ma
----------------
lukel97 wrote:

The `call i64 @llvm.riscv.vsetvli.i64(i64 %n, i64 2, i64 0)` in the loop body is getting hoisted out by LICM. But phi %1 is actually loop invariant because the two vsetvlis are the same, opt will remove it. Should it be `%8 = tail call i64 @llvm.riscv.vsetvli.i64(i64 %i, i64 2, i64 0)` instead?


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


More information about the llvm-commits mailing list