[llvm] [RISCV] Reduce VL of vmerge.vvm's true operand (PR #105786)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 23:12:47 PDT 2024
https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/105786
This extends the peephole added in #104689 to also reduce the VL of a PseudoVMERGE_VVM's true operand.
We could extend this later to reduce the false operand as well, but this starts with just the true operand since it allows vmerges that are converted to vmv.v.vs (convertVMergeToVMv) to be potentially further folded into their source (foldVMV_V_V).
>From d476887692b72d873434184bf26f6d37357a691e Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Fri, 23 Aug 2024 14:05:50 +0800
Subject: [PATCH] [RISCV] Reduce VL of vmerge.vvm's true operand
This extends the peephole added in #104689 to also reduce the VL of a PseudoVMERGE_VVM's true operand.
We could extend this later to reduce the false operand as well, but this starts with just the true operand since it allows vmerges that are converted to vmv.v.vs (convertVMergeToVMv) to be potentially further folded into their source (foldVMV_V_V).
---
llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp | 3 +++
llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll | 3 +--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp b/llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp
index 9772782ad3d6db..8eb1586799f5e8 100644
--- a/llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp
+++ b/llvm/lib/Target/RISCV/RISCVVectorPeephole.cpp
@@ -131,6 +131,9 @@ bool RISCVVectorPeephole::tryToReduceVL(MachineInstr &MI) const {
case RISCV::VMV_V_V:
SrcIdx = 2;
break;
+ case RISCV::VMERGE_VVM:
+ SrcIdx = 3; // TODO: We can also handle the false operand.
+ break;
}
MachineOperand &VL = MI.getOperand(RISCVII::getVLOpNum(MI.getDesc()));
diff --git a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
index 39055dc5adfcf7..6700920cebff0a 100644
--- a/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
@@ -1072,9 +1072,8 @@ define <vscale x 2 x i32> @vmerge_larger_vl_same_passthru(<vscale x 2 x i32> %pa
define <vscale x 2 x i32> @vmerge_smaller_vl_different_passthru(<vscale x 2 x i32> %pt1, <vscale x 2 x i32> %pt2, <vscale x 2 x i32> %x, <vscale x 2 x i32> %y, <vscale x 2 x i1> %m) {
; CHECK-LABEL: vmerge_smaller_vl_different_passthru:
; CHECK: # %bb.0:
-; CHECK-NEXT: vsetivli zero, 3, e32, m1, tu, ma
-; CHECK-NEXT: vadd.vv v8, v10, v11
; CHECK-NEXT: vsetivli zero, 2, e32, m1, tu, ma
+; CHECK-NEXT: vadd.vv v8, v10, v11
; CHECK-NEXT: vmerge.vvm v9, v9, v8, v0
; CHECK-NEXT: vmv1r.v v8, v9
; CHECK-NEXT: ret
More information about the llvm-commits
mailing list