Skip to content

Commit 26ff4c6

Browse files
committed
[RISCV] Add SDNode patterns for vandn.[vv,vx]
Unfortunately we can't use the standard splat_vector and vnot PatFrags because they are preprocessed to vmv.v.x's, so we need to define helpers to catch those. We can't use SplatPat either because we need to nest another fragment inside of it. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D155433
1 parent db39328 commit 26ff4c6

File tree

2 files changed

+2036
-0
lines changed

2 files changed

+2036
-0
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ let Predicates = [HasStdExtZvksh], RVVConstraint = NoConstraint in {
182182
// Pseudo instructions
183183
//===----------------------------------------------------------------------===//
184184

185+
defm PseudoVANDN : VPseudoVALU_VV_VX;
186+
185187
multiclass VPseudoUnaryV_V {
186188
foreach m = MxList in {
187189
let VLMul = m.value in {
@@ -215,6 +217,34 @@ multiclass VPatUnarySDNode_V<SDPatternOperator op, string instruction_name> {
215217
}
216218
}
217219

220+
// Helpers for detecting splats since we preprocess splat_vector to vmv.v.x
221+
// This should match the logic in RISCVDAGToDAGISel::selectVSplat
222+
def riscv_splat_vector : PatFrag<(ops node:$rs1),
223+
(riscv_vmv_v_x_vl undef, node:$rs1, srcvalue)>;
224+
def riscv_vnot : PatFrag<(ops node:$rs1), (xor node:$rs1,
225+
(riscv_splat_vector -1))>;
226+
227+
foreach vti = AllIntegerVectors in {
228+
let Predicates = !listconcat([HasStdExtZvbb],
229+
GetVTypePredicates<vti>.Predicates) in {
230+
def : Pat<(vti.Vector (and (riscv_vnot vti.RegClass:$rs1),
231+
vti.RegClass:$rs2)),
232+
(!cast<Instruction>("PseudoVANDN_VV_"#vti.LMul.MX)
233+
(vti.Vector (IMPLICIT_DEF)),
234+
vti.RegClass:$rs2,
235+
vti.RegClass:$rs1,
236+
vti.AVL, vti.Log2SEW, TA_MA)>;
237+
def : Pat<(vti.Vector (and (riscv_splat_vector
238+
(not vti.ScalarRegClass:$rs1)),
239+
vti.RegClass:$rs2)),
240+
(!cast<Instruction>("PseudoVANDN_VX_"#vti.LMul.MX)
241+
(vti.Vector (IMPLICIT_DEF)),
242+
vti.RegClass:$rs2,
243+
vti.ScalarRegClass:$rs1,
244+
vti.AVL, vti.Log2SEW, TA_MA)>;
245+
}
246+
}
247+
218248
defm : VPatUnarySDNode_V<bitreverse, "PseudoVBREV">;
219249
defm : VPatUnarySDNode_V<bswap, "PseudoVREV8">;
220250
defm : VPatUnarySDNode_V<ctlz, "PseudoVCLZ">;

0 commit comments

Comments
 (0)