diff --git a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll b/llvm/test/CodeGen/RISCV/rvv/vmv.v.v-peephole.ll similarity index 73% rename from llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll rename to llvm/test/CodeGen/RISCV/rvv/vmv.v.v-peephole.ll index ec03f773c71082..8a589a31a15351 100644 --- a/llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vmv.v.v-peephole.ll @@ -2,20 +2,14 @@ ; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs | FileCheck %s ; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs | FileCheck %s -declare @llvm.riscv.vmv.v.v.nxv4i32(, , iXLen) - -declare @llvm.riscv.vadd.nxv4i32.nxv4i32(, , , iXLen) - -define @vadd( %passthru, %a, %b, iXLen %vl1, iXLen %vl2) { +define @vadd( %passthru, %a, %b, iXLen %vl) { ; CHECK-LABEL: vadd: ; CHECK: # %bb.0: -; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma -; CHECK-NEXT: vadd.vv v10, v10, v12 -; CHECK-NEXT: vsetvli zero, a1, e32, m2, tu, ma -; CHECK-NEXT: vmv.v.v v8, v10 +; CHECK-NEXT: vsetvli zero, a0, e32, m2, tu, ma +; CHECK-NEXT: vadd.vv v8, v10, v12 ; CHECK-NEXT: ret - %v = call @llvm.riscv.vadd.nxv4i32.nxv4i32( poison, %a, %b, iXLen %vl1) - %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl2) + %v = call @llvm.riscv.vadd.nxv4i32.nxv4i32( poison, %a, %b, iXLen %vl) + %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl) ret %w } @@ -30,23 +24,31 @@ define @vadd_mask( %passthru, %w } -define @vadd_undef( %a, %b, iXLen %vl1, iXLen %vl2) { +define @vadd_undef( %a, %b, iXLen %vl) { ; CHECK-LABEL: vadd_undef: ; CHECK: # %bb.0: ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma ; CHECK-NEXT: vadd.vv v8, v8, v10 -; CHECK-NEXT: vsetvli zero, a1, e32, m2, ta, ma -; CHECK-NEXT: vmv.v.v v8, v8 ; CHECK-NEXT: ret - %v = call @llvm.riscv.vadd.nxv4i32.nxv4i32( poison, %a, %b, iXLen %vl1) - %w = call @llvm.riscv.vmv.v.v.nxv4i32( poison, %v, iXLen %vl2) + %v = call @llvm.riscv.vadd.nxv4i32.nxv4i32( poison, %a, %b, iXLen %vl) + %w = call @llvm.riscv.vmv.v.v.nxv4i32( poison, %v, iXLen %vl) ret %w } -; TODO: Is this correct if there's already a passthru in the src? -define @vadd_same_passthru( %passthru, %a, %b, iXLen %vl1, iXLen %vl2) { +define @vadd_same_passthru( %passthru, %a, %b, iXLen %vl) { ; CHECK-LABEL: vadd_same_passthru: ; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli zero, a0, e32, m2, tu, ma +; CHECK-NEXT: vadd.vv v8, v10, v12 +; CHECK-NEXT: ret + %v = call @llvm.riscv.vadd.nxv4i32.nxv4i32( %passthru, %a, %b, iXLen %vl) + %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl) + ret %w +} + +define @unfoldable_diff_avl_unknown( %passthru, %a, %b, iXLen %vl1, iXLen %vl2) { +; CHECK-LABEL: unfoldable_diff_avl_unknown: +; CHECK: # %bb.0: ; CHECK-NEXT: vmv2r.v v14, v8 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, tu, ma ; CHECK-NEXT: vadd.vv v14, v10, v12 @@ -58,36 +60,50 @@ define @vadd_same_passthru( %passthru, %w } -declare @llvm.riscv.vadd.mask.nxv4i32.nxv4i32(, , , , iXLen, iXLen) +define @diff_avl_known( %passthru, %a, %b) { +; CHECK-LABEL: diff_avl_known: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 4, e32, m2, tu, ma +; CHECK-NEXT: vadd.vv v8, v10, v12 +; CHECK-NEXT: ret + %v = call @llvm.riscv.vadd.nxv4i32.nxv4i32( %passthru, %a, %b, iXLen 4) + %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen 8) + ret %w +} + +define @diff_avl_vlmax( %passthru, %a, %b, iXLen %vl) { +; CHECK-LABEL: diff_avl_vlmax: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli zero, a0, e32, m2, tu, ma +; CHECK-NEXT: vadd.vv v8, v10, v12 +; CHECK-NEXT: ret + %v = call @llvm.riscv.vadd.nxv4i32.nxv4i32( %passthru, %a, %b, iXLen -1) + %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl) + ret %w +} -define @vadd_mask_ma( %passthru, %a, %b, %mask, iXLen %vl1, iXLen %vl2) { +define @vadd_mask_ma( %passthru, %a, %b, %mask, iXLen %vl) { ; CHECK-LABEL: vadd_mask_ma: ; CHECK: # %bb.0: -; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma -; CHECK-NEXT: vadd.vv v10, v10, v12, v0.t -; CHECK-NEXT: vsetvli zero, a1, e32, m2, tu, ma -; CHECK-NEXT: vmv.v.v v8, v10 +; CHECK-NEXT: vsetvli zero, a0, e32, m2, tu, mu +; CHECK-NEXT: vadd.vv v8, v10, v12, v0.t ; CHECK-NEXT: ret - %v = call @llvm.riscv.vadd.mask.nxv4i32.nxv4i32( poison, %a, %b, %mask, iXLen %vl1, iXLen 2) - %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl2) + %v = call @llvm.riscv.vadd.mask.nxv4i32.nxv4i32( poison, %a, %b, %mask, iXLen %vl, iXLen 2) + %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl) ret %w } -define @vadd_mask_mu( %passthru, %a, %b, %mask, iXLen %vl1, iXLen %vl2) { +define @vadd_mask_mu( %passthru, %a, %b, %mask, iXLen %vl) { ; CHECK-LABEL: vadd_mask_mu: ; CHECK: # %bb.0: -; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma -; CHECK-NEXT: vadd.vv v10, v10, v12, v0.t -; CHECK-NEXT: vsetvli zero, a1, e32, m2, tu, ma -; CHECK-NEXT: vmv.v.v v8, v10 +; CHECK-NEXT: vsetvli zero, a0, e32, m2, tu, mu +; CHECK-NEXT: vadd.vv v8, v10, v12, v0.t ; CHECK-NEXT: ret - %v = call @llvm.riscv.vadd.mask.nxv4i32.nxv4i32( poison, %a, %b, %mask, iXLen %vl1, iXLen 0) - %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl2) + %v = call @llvm.riscv.vadd.mask.nxv4i32.nxv4i32( poison, %a, %b, %mask, iXLen %vl, iXLen 0) + %w = call @llvm.riscv.vmv.v.v.nxv4i32( %passthru, %v, iXLen %vl) ret %w } -declare @llvm.riscv.vle.nxv4i32(, ptr, iXLen) - define @foldable_load( %passthru, ptr %p) { ; CHECK-LABEL: foldable_load: ; CHECK: # %bb.0: @@ -113,10 +129,6 @@ define @unfoldable_load( %passthru, ptr %p, ret %w } -declare @llvm.riscv.vmv.v.v.nxv4f32(, , iXLen) - -declare @llvm.riscv.vfadd.nxv4f32.nxv4f32(, , , iXLen, iXLen) - define @unfoldable_vfadd( %passthru, %a, %b, iXLen %vl1, iXLen %vl2) { ; CHECK-LABEL: unfoldable_vfadd: ; CHECK: # %bb.0: