Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19709,6 +19709,19 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
if (SDValue V = combineToVCPOP(N, DAG, Subtarget))
return V;
break;
case RISCVISD::VRGATHER_VX_VL: {
// Drop a redundant vrgather_vx.
// Note this assumes that out of bounds indices produce poison
// and can thus be replaced without having to prove them inbounds..
SDValue Src = N->getOperand(0);
SDValue Passthru = N->getOperand(2);
SDValue VL = N->getOperand(4);
// TODO: Handle fmv.v.f?
if (Src.getOpcode() == RISCVISD::VMV_V_X_VL && Passthru.isUndef() &&
VL == Src.getOperand(2))
return Src;
break;
}
}

return SDValue();
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/RISCV/RISCVISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ enum NodeType : unsigned {
VMSET_VL,

// Matches the semantics of vrgather.vx and vrgather.vv with extra operands
// for passthru and VL. Operands are (src, index, mask, passthru, vl).
// for passthru and VL, except that out of bound indices result in a poison
// result not zero. Operands are (src, index, mask, passthru, vl).
VRGATHER_VX_VL,
VRGATHER_VV_VL,
VRGATHEREI16_VV_VL,
Expand Down
5 changes: 2 additions & 3 deletions llvm/test/CodeGen/RISCV/rvv/fixed-vectors-shuffle-int.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1346,10 +1346,9 @@ define <4 x i16> @vmerge_2(<4 x i16> %x) {
define <4 x i16> @vmerge_3(<4 x i16> %x) {
; CHECK-LABEL: vmerge_3:
; CHECK: # %bb.0:
; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, mu
; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
; CHECK-NEXT: vmv.v.i v0, 6
; CHECK-NEXT: vmv.v.i v9, 5
; CHECK-NEXT: vrgather.vi v8, v9, 1, v0.t
; CHECK-NEXT: vmerge.vim v8, v8, 5, v0
; CHECK-NEXT: ret
%s = shufflevector <4 x i16> %x, <4 x i16> <i16 poison, i16 5, i16 poison, i16 poison>, <4 x i32> <i32 0, i32 5, i32 5, i32 3>
ret <4 x i16> %s
Expand Down