Skip to content

Commit a25e006

Browse files
toppercpfusik
authored andcommitted
[RISCV] Match VANDN ignoring XOR constant bits above SEW
1 parent b52efb4 commit a25e006

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,13 +603,16 @@ multiclass VPatUnarySDNode_V<SDPatternOperator op, string instruction_name,
603603
// This should match the logic in RISCVDAGToDAGISel::selectVSplat
604604
def riscv_splat_vector : PatFrag<(ops node:$rs1),
605605
(riscv_vmv_v_x_vl undef, node:$rs1, srcvalue)>;
606-
def riscv_vnot : PatFrag<(ops node:$rs1), (xor node:$rs1,
607-
(riscv_splat_vector -1))>;
606+
def allonessew8 : ImmLeaf<XLenVT, "return SignExtend64<8>(Imm) == -1LL;">;
607+
def allonessew16 : ImmLeaf<XLenVT, "return SignExtend64<16>(Imm) == -1LL;">;
608+
def allonessew32 : ImmLeaf<XLenVT, "return SignExtend64<32>(Imm) == -1LL;">;
609+
def allonessew64 : ImmLeaf<XLenVT, "return Imm == -1LL;">;
608610

609611
foreach vti = AllIntegerVectors in {
610612
let Predicates = !listconcat([HasStdExtZvkb],
611613
GetVTypePredicates<vti>.Predicates) in {
612-
def : Pat<(vti.Vector (and (riscv_vnot vti.RegClass:$rs1),
614+
def : Pat<(vti.Vector (and (xor vti.RegClass:$rs1,
615+
(riscv_splat_vector !cast<ImmLeaf>("allonessew"#vti.SEW))),
613616
vti.RegClass:$rs2)),
614617
(!cast<Instruction>("PseudoVANDN_VV_"#vti.LMul.MX)
615618
(vti.Vector (IMPLICIT_DEF)),

llvm/test/CodeGen/RISCV/rvv/vandn-sdnode.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,8 +2581,7 @@ define <vscale x 1 x i8> @not_signbit_mask_nxv1i8(<vscale x 1 x i8> %a, <vscale
25812581
; CHECK-ZVKB: # %bb.0:
25822582
; CHECK-ZVKB-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
25832583
; CHECK-ZVKB-NEXT: vsra.vi v8, v8, 7
2584-
; CHECK-ZVKB-NEXT: vnot.v v8, v8
2585-
; CHECK-ZVKB-NEXT: vand.vv v8, v8, v9
2584+
; CHECK-ZVKB-NEXT: vandn.vv v8, v9, v8
25862585
; CHECK-ZVKB-NEXT: ret
25872586
%cond = icmp sgt <vscale x 1 x i8> %a, splat (i8 -1)
25882587
%r = select <vscale x 1 x i1> %cond, <vscale x 1 x i8> %b, <vscale x 1 x i8> zeroinitializer

0 commit comments

Comments
 (0)