diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td @@ -605,6 +605,83 @@ } } +class VPatBinaryMaskSDNode_VV : + Pat<(result_type (vop (op_type op_reg_class:$rs1), + (op_type (vselect (mask_type V0), + (op_type op_reg_class:$rs2), + (riscv_vmv_v_x_vl + (op_type undef), imm, + (XLenVT srcvalue)))))), + (!cast(instruction_name#"_VV_"# vlmul.MX#"_MASK") + op_reg_class:$rs1, + op_reg_class:$rs1, + op_reg_class:$rs2, + (mask_type V0), + avl, sew, TAIL_AGNOSTIC)>; + +class VPatBinaryMaskSDNode_XI : + Pat<(result_type (vop + (vop_type vop_reg_class:$rs1), + (vop_type (vselect (mask_type V0), + (vop_type (SplatPatKind xop_kind:$rs2)), + (riscv_vmv_v_x_vl + (vop_type undef), imm, + (XLenVT srcvalue)))))), + (!cast(instruction_name#_#suffix#_# vlmul.MX#"_MASK") + vop_reg_class:$rs1, + vop_reg_class:$rs1, + xop_kind:$rs2, + (mask_type V0), + avl, sew, TAIL_AGNOSTIC)>; + + +multiclass VPatBinaryMaskSDNode_VV_VX { + foreach vti = AllIntegerVectors in { + def : VPatBinaryMaskSDNode_VV; + def : VPatBinaryMaskSDNode_XI; + } +} + +multiclass VPatBinaryMaskSDNode_VV_VX_VI + : VPatBinaryMaskSDNode_VV_VX { + foreach vti = AllIntegerVectors in { + def : VPatBinaryMaskSDNode_XI(SplatPat#_#ImmType), + ImmType, imm>; + } +} + //===----------------------------------------------------------------------===// // Patterns. //===----------------------------------------------------------------------===// @@ -627,7 +704,11 @@ // 12.1. Vector Single-Width Integer Add and Subtract defm : VPatBinarySDNode_VV_VX_VI; +defm : VPatBinaryMaskSDNode_VV_VX_VI; + defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; + // Handle VRSUB specially since it's the only integer binary op with reversed // pattern operands foreach vti = AllIntegerVectors in { @@ -666,13 +747,19 @@ // 12.5. Vector Bitwise Logical Instructions defm : VPatBinarySDNode_VV_VX_VI; +defm : VPatBinaryMaskSDNode_VV_VX_VI; defm : VPatBinarySDNode_VV_VX_VI; +defm : VPatBinaryMaskSDNode_VV_VX_VI; defm : VPatBinarySDNode_VV_VX_VI; +defm : VPatBinaryMaskSDNode_VV_VX_VI; // 12.6. Vector Single-Width Bit Shift Instructions defm : VPatBinarySDNode_VV_VX_VI; +defm : VPatBinaryMaskSDNode_VV_VX_VI; defm : VPatBinarySDNode_VV_VX_VI; +defm : VPatBinaryMaskSDNode_VV_VX_VI; defm : VPatBinarySDNode_VV_VX_VI; +defm : VPatBinaryMaskSDNode_VV_VX_VI; foreach vti = AllIntegerVectors in { // Emit shift by 1 as an add since it might be faster. @@ -720,20 +807,29 @@ // 12.9. Vector Integer Min/Max Instructions defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; // 12.10. Vector Single-Width Integer Multiply Instructions defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; // 12.11. Vector Integer Divide Instructions defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; defm : VPatBinarySDNode_VV_VX; +defm : VPatBinaryMaskSDNode_VV_VX; // 12.12. Vector Widening Integer Multiply Instructions defm : VPatWidenBinarySDNode_VV_VX %splat1, %splat2 ret %v } + +define @vadd_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vadd_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vadd.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %vs = select %mask, %vb, zeroinitializer + %vc = add %va, %vs + ret %vc +} + +define @vadd_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vadd_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vadd.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = add %va, %vs + ret %vc +} + +define @vadd_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vadd_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vadd.vi v8, v8, 7, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = add %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vand-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vand-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vand-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vand-sdnode.ll @@ -1381,3 +1381,46 @@ %v = and %splat1, %splat2 ret %v } + +define @vand_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vand_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vand.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 -1, i32 0 + %allones = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %vb, %allones + %vc = and %va, %vs + ret %vc +} + +define @vand_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vand_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vand.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 -1, i32 0 + %allones = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %allones + %vc = and %va, %vs + ret %vc +} + +define @vand_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vand_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vand.vi v8, v8, 7, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 -1, i32 0 + %allones = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %allones + %vc = and %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vdiv-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vdiv-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vdiv-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vdiv-sdnode.ll @@ -1184,3 +1184,47 @@ %vc = sdiv %va, %splat ret %vc } + +define @vdiv_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vdiv_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vdiv.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 1, i32 0 + %one = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %vb, %one + %vc = sdiv %va, %vs + ret %vc +} + +define @vdiv_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vdiv_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vdiv.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = sdiv %va, %vs + ret %vc +} + +define @vdiv_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vdiv_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vdiv.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = sdiv %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vdivu-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vdivu-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vdivu-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vdivu-sdnode.ll @@ -1197,3 +1197,47 @@ %vd = udiv %va, %vc ret %vd } + +define @vdivu_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vdivu_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vdivu.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 1, i32 0 + %one = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %vb, %one + %vc = udiv %va, %vs + ret %vc +} + +define @vdivu_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vdivu_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vdivu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = udiv %va, %vs + ret %vc +} + +define @vdivu_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vdivu_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vdivu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = udiv %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vmaxu-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vmaxu-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vmaxu-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vmaxu-sdnode.ll @@ -890,3 +890,43 @@ ret %vc } +define @vmax_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vmax_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vmaxu.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %vs = select %mask, %vb, zeroinitializer + %cmp = icmp ugt %va, %vs + %vc = select %cmp, %va, %vs + ret %vc +} + +define @vmax_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vmax_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmaxu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %cmp = icmp ugt %va, %vs + %vc = select %cmp, %va, %vs + ret %vc +} + +define @vmax_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vmax_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, -3 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmaxu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 -3, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %cmp = icmp ugt %va, %vs + %vc = select %cmp, %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vminu-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vminu-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vminu-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vminu-sdnode.ll @@ -890,3 +890,49 @@ ret %vc } +define @vmin_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vmin_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vminu.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 -1, i32 0 + %max = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %vb, %max + %cmp = icmp ult %va, %vs + %vc = select %cmp, %va, %vs + ret %vc +} + +define @vmin_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vmin_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vminu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 -1, i32 0 + %max = shufflevector %head0, poison, zeroinitializer + %head1 = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head1, poison, zeroinitializer + %vs = select %mask, %splat, %max + %cmp = icmp ult %va, %vs + %vc = select %cmp, %va, %vs + ret %vc +} + +define @vmin_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vmin_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, -3 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vminu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 -1, i32 0 + %max = shufflevector %head0, poison, zeroinitializer + %head1 = insertelement poison, i32 -3, i32 0 + %splat = shufflevector %head1, poison, zeroinitializer + %vs = select %mask, %splat, %max + %cmp = icmp ult %va, %vs + %vc = select %cmp, %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vmul-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vmul-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vmul-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vmul-sdnode.ll @@ -959,3 +959,48 @@ %v = mul %splat1, %splat2 ret %v } + +define @vmul_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vmul_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vmul.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 1, i32 0 + %one = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %vb, %one + %vc = mul %va, %vs + ret %vc +} + +define @vmul_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vmul_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmul.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = mul %va, %vs + ret %vc +} + +define @vmul_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vmul_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmul.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = mul %va, %vs + ret %vc +} + diff --git a/llvm/test/CodeGen/RISCV/rvv/vmulh-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vmulh-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vmulh-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vmulh-sdnode.ll @@ -348,3 +348,65 @@ %vf = trunc %ve to ret %vf } + +define @vmulh_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vmulh_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vmulh.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head0, poison, zeroinitializer + %vs = select %mask, %vb, %one + %vc = sext %vs to + %vd = sext %va to + %ve = mul %vc, %vd + %head1 = insertelement poison, i64 32, i32 0 + %splat = shufflevector %head1, poison, zeroinitializer + %vf = lshr %ve, %splat + %vg = trunc %vf to + ret %vg +} + +define @vmulh_vx_mask_nxv8i32( %va, i32 signext %x, %mask) { +; CHECK-LABEL: vmulh_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmulh.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head0, poison, zeroinitializer + %head1 = insertelement poison, i32 %x, i32 0 + %splat1 = shufflevector %head1, poison, zeroinitializer + %vs = select %mask, %splat1, %one + %vb = sext %vs to + %vc = sext %va to + %vd = mul %vb, %vc + %head2 = insertelement poison, i64 32, i32 0 + %splat2 = shufflevector %head2, poison, zeroinitializer + %ve = lshr %vd, %splat2 + %vf = trunc %ve to + ret %vf +} + +define @vmulh_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vmulh_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmulh.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head0, poison, zeroinitializer + %head1 = insertelement poison, i32 7, i32 0 + %splat1 = shufflevector %head1, poison, zeroinitializer + %vs = select %mask, %splat1, %one + %vb = sext %vs to + %vc = sext %va to + %vd = mul %vb, %vc + %head2 = insertelement poison, i64 32, i32 0 + %splat2 = shufflevector %head2, poison, zeroinitializer + %ve = lshr %vd, %splat2 + %vf = trunc %ve to + ret %vf +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vmulhu-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vmulhu-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vmulhu-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vmulhu-sdnode.ll @@ -349,3 +349,65 @@ %vf = trunc %ve to ret %vf } + +define @vmulhu_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vmulhu_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vmulhu.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head0, poison, zeroinitializer + %vs = select %mask, %vb, %one + %vc = zext %vs to + %vd = zext %va to + %ve = mul %vc, %vd + %head1 = insertelement poison, i64 32, i32 0 + %splat = shufflevector %head1, poison, zeroinitializer + %vf = lshr %ve, %splat + %vg = trunc %vf to + ret %vg +} + +define @vmulhu_vx_mask_nxv8i32( %va, i32 signext %x, %mask) { +; CHECK-LABEL: vmulhu_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmulhu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head0, poison, zeroinitializer + %head1 = insertelement poison, i32 %x, i32 0 + %splat1 = shufflevector %head1, poison, zeroinitializer + %vs = select %mask, %splat1, %one + %vb = zext %vs to + %vc = zext %va to + %vd = mul %vb, %vc + %head2 = insertelement poison, i64 32, i32 0 + %splat2 = shufflevector %head2, poison, zeroinitializer + %ve = lshr %vd, %splat2 + %vf = trunc %ve to + ret %vf +} + +define @vmulhu_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vmulhu_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vmulhu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head0 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head0, poison, zeroinitializer + %head1 = insertelement poison, i32 7, i32 0 + %splat1 = shufflevector %head1, poison, zeroinitializer + %vs = select %mask, %splat1, %one + %vb = zext %vs to + %vc = zext %va to + %vd = mul %vb, %vc + %head2 = insertelement poison, i64 32, i32 0 + %splat2 = shufflevector %head2, poison, zeroinitializer + %ve = lshr %vd, %splat2 + %vf = trunc %ve to + ret %vf +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vor-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vor-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vor-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vor-sdnode.ll @@ -1174,3 +1174,40 @@ %v = or %splat1, %splat2 ret %v } + +define @vor_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vor_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vor.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %vs = select %mask, %vb, zeroinitializer + %vc = or %va, %vs + ret %vc +} + +define @vor_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vor_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vor.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = or %va, %vs + ret %vc +} + +define @vor_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vor_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vor.vi v8, v8, 7, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = or %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vrem-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vrem-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vrem-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vrem-sdnode.ll @@ -1235,3 +1235,48 @@ ret %vc } + +define @vrem_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vrem_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vrem.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 1, i32 0 + %one = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %vb, %one + %vc = srem %va, %vs + ret %vc +} + +define @vrem_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vrem_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vrem.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = srem %va, %vs + ret %vc +} + +define @vrem_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vrem_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vrem.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = srem %va, %vs + ret %vc +} + diff --git a/llvm/test/CodeGen/RISCV/rvv/vremu-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vremu-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vremu-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vremu-sdnode.ll @@ -1263,3 +1263,47 @@ %vd = urem %va, %vc ret %vd } + +define @vremu_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vremu_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vremu.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 1, i32 0 + %one = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %vb, %one + %vc = urem %va, %vs + ret %vc +} + +define @vremu_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vremu_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vremu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = urem %va, %vs + ret %vc +} + +define @vremu_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vremu_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vremu.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head1 = insertelement poison, i32 1, i32 0 + %one = shufflevector %head1, poison, zeroinitializer + %head2 = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head2, poison, zeroinitializer + %vs = select %mask, %splat, %one + %vc = urem %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vshl-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vshl-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vshl-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vshl-sdnode.ll @@ -629,3 +629,40 @@ %vc = shl %va, %splat ret %vc } + +define @vshl_vv_mask_nxv4i32( %va, %vb, %mask) { +; CHECK-LABEL: vshl_vv_mask_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vsll.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %vs = select %mask, %vb, zeroinitializer + %vc = shl %va, %vs + ret %vc +} + +define @vshl_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vshl_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vsll.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = shl %va, %vs + ret %vc +} + +define @vshl_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vshl_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vsll.vi v8, v8, 31, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 31, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = shl %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vsra-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vsra-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vsra-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vsra-sdnode.ll @@ -802,3 +802,39 @@ ret %vc } +define @vsra_vv_mask_nxv4i32( %va, %vb, %mask) { +; CHECK-LABEL: vsra_vv_mask_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vsra.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %vs = select %mask, %vb, zeroinitializer + %vc = ashr %va, %vs + ret %vc +} + +define @vsra_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vsra_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vsra.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = ashr %va, %vs + ret %vc +} + +define @vsra_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vsra_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vsra.vi v8, v8, 31, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 31, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = ashr %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vsrl-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vsrl-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vsrl-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vsrl-sdnode.ll @@ -582,3 +582,39 @@ ret %vc } +define @vsrl_vv_mask_nxv4i32( %va, %vb, %mask) { +; CHECK-LABEL: vsrl_vv_mask_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vsrl.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %vs = select %mask, %vb, zeroinitializer + %vc = lshr %va, %vs + ret %vc +} + +define @vsrl_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vsrl_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vsrl.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = lshr %va, %vs + ret %vc +} + +define @vsrl_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vsrl_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vsrl.vi v8, v8, 31, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 31, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = lshr %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vsub-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vsub-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vsub-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vsub-sdnode.ll @@ -868,3 +868,42 @@ %v = sub %splat1, %splat2 ret %v } + +define @vsub_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vsub_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vsub.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + + %vs = select %mask, %vb, zeroinitializer + %vc = sub %va, %vs + ret %vc +} + +define @vsub_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vsub_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vsub.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = sub %va, %vs + ret %vc +} + +define @vsub_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vsub_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: li a0, 7 +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vsub.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = sub %va, %vs + ret %vc +} diff --git a/llvm/test/CodeGen/RISCV/rvv/vxor-sdnode.ll b/llvm/test/CodeGen/RISCV/rvv/vxor-sdnode.ll --- a/llvm/test/CodeGen/RISCV/rvv/vxor-sdnode.ll +++ b/llvm/test/CodeGen/RISCV/rvv/vxor-sdnode.ll @@ -1381,3 +1381,40 @@ %v = xor %splat1, %splat2 ret %v } + +define @vxor_vv_mask_nxv8i32( %va, %vb, %mask) { +; CHECK-LABEL: vxor_vv_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vxor.vv v8, v8, v12, v0.t +; CHECK-NEXT: ret + %vs = select %mask, %vb, zeroinitializer + %vc = xor %va, %vs + ret %vc +} + +define @vxor_vx_mask_nxv8i32( %va, i32 signext %b, %mask) { +; CHECK-LABEL: vxor_vx_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, mu +; CHECK-NEXT: vxor.vx v8, v8, a0, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 %b, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = xor %va, %vs + ret %vc +} + +define @vxor_vi_mask_nxv8i32( %va, %mask) { +; CHECK-LABEL: vxor_vi_mask_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32, m4, ta, mu +; CHECK-NEXT: vxor.vi v8, v8, 7, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i32 7, i32 0 + %splat = shufflevector %head, poison, zeroinitializer + %vs = select %mask, %splat, zeroinitializer + %vc = xor %va, %vs + ret %vc +}