From 6518c410e869a6faed30941308c57e341f1fff6b Mon Sep 17 00:00:00 2001 From: Kiva Date: Thu, 11 Apr 2024 14:30:16 +0800 Subject: [PATCH] [LLVM][XTHeadVector] Implement 16.2-16.6 `vmpopc/vmfirst/vmsbf/vmsif/vmsof` (#97) * [LLVM][XTHeadVector] Implement 16.2-16.6 `vmpopc/vmfirst/vmsbf/vmsif/vmsof` * [LLVM][XTHeadVector] Test 16.2~16.6 `vmpopc/vmfirst/vmsbf/vmsif/vmsof` --- .../include/llvm/IR/IntrinsicsRISCVXTHeadV.td | 11 + .../RISCV/RISCVInstrInfoXTHeadVPseudos.td | 123 ++++++++ llvm/test/CodeGen/RISCV/rvv0p71/vmfirst.ll | 229 +++++++++++++++ llvm/test/CodeGen/RISCV/rvv0p71/vmpopc.ll | 229 +++++++++++++++ llvm/test/CodeGen/RISCV/rvv0p71/vmsbf.ll | 277 ++++++++++++++++++ llvm/test/CodeGen/RISCV/rvv0p71/vmsif.ll | 277 ++++++++++++++++++ llvm/test/CodeGen/RISCV/rvv0p71/vmsof.ll | 277 ++++++++++++++++++ 7 files changed, 1423 insertions(+) create mode 100644 llvm/test/CodeGen/RISCV/rvv0p71/vmfirst.ll create mode 100644 llvm/test/CodeGen/RISCV/rvv0p71/vmpopc.ll create mode 100644 llvm/test/CodeGen/RISCV/rvv0p71/vmsbf.ll create mode 100644 llvm/test/CodeGen/RISCV/rvv0p71/vmsif.ll create mode 100644 llvm/test/CodeGen/RISCV/rvv0p71/vmsof.ll diff --git a/llvm/include/llvm/IR/IntrinsicsRISCVXTHeadV.td b/llvm/include/llvm/IR/IntrinsicsRISCVXTHeadV.td index 5b71bc71e26df3..0458eb3106f612 100644 --- a/llvm/include/llvm/IR/IntrinsicsRISCVXTHeadV.td +++ b/llvm/include/llvm/IR/IntrinsicsRISCVXTHeadV.td @@ -910,4 +910,15 @@ let TargetPrefix = "riscv" in { def int_riscv_th_vmclr : RISCVNullaryIntrinsic; def int_riscv_th_vmset : RISCVNullaryIntrinsic; + // 16.2. Vector mask population count vpopc + defm th_vmpopc : RISCVMaskedUnarySOut; + // 16.3. vfirst find-first-set mask bit + defm th_vmfirst : RISCVMaskedUnarySOut; + // 16.4. vmsbf.m set-before-first mask bit + defm th_vmsbf : RISCVMaskedUnaryMOut; + // 16.5. vmsif.m set-including-first mask bit + defm th_vmsif : RISCVMaskedUnaryMOut; + // 16.6. vmsof.m set-only-first mask bit + defm th_vmsof : RISCVMaskedUnaryMOut; + } // TargetPrefix = "riscv" diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXTHeadVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXTHeadVPseudos.td index 7c7c9ac7289883..efe9ac8a07937e 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoXTHeadVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXTHeadVPseudos.td @@ -1744,6 +1744,19 @@ class XVPseudoTiedBinaryMaskRoundingMode : + Pseudo<(outs GetVRegNoV0.R:$rd), + (ins GetVRegNoV0.R:$merge, OpClass:$rs2, + VMaskOp:$vm, AVL:$vl, ixlenimm:$sew), []>, + RISCVVPseudo { + let mayLoad = 0; + let mayStore = 0; + let hasSideEffects = 0; + let Constraints = !interleave([Constraint, "$rd = $merge"], ","); + let HasVLOp = 1; + let HasSEWOp = 1; +} + multiclass XVPseudoBinary("WriteVMPopV_" # mx); + defvar ReadVMPopV_MX = !cast("ReadVMPopV_" # mx); + let VLMul = mti.LMul.value in { + def "_M_" # mti.BX : VPseudoUnaryNoMaskGPROut, + Sched<[WriteVMPopV_MX, ReadVMPopV_MX, ReadVMPopV_MX]>; + def "_M_" # mti.BX # "_MASK" : VPseudoUnaryMaskGPROut, + Sched<[WriteVMPopV_MX, ReadVMPopV_MX, ReadVMPopV_MX]>; + } + } +} + +multiclass XVPseudoV1ST_M { + foreach mti = AllXMasks in { + defvar mx = mti.LMul.MX; + defvar WriteVMFFSV_MX = !cast("WriteVMFFSV_" # mx); + defvar ReadVMFFSV_MX = !cast("ReadVMFFSV_" # mx); + let VLMul = mti.LMul.value in { + def "_M_" # mti.BX : VPseudoUnaryNoMaskGPROut, + Sched<[WriteVMFFSV_MX, ReadVMFFSV_MX, ReadVMFFSV_MX]>; + def "_M_" # mti.BX # "_MASK" : VPseudoUnaryMaskGPROut, + Sched<[WriteVMFFSV_MX, ReadVMFFSV_MX, ReadVMFFSV_MX]>; + } + } +} + +multiclass XVPseudoVSFS_M { + defvar constraint = "@earlyclobber $rd"; + foreach mti = AllXMasks in { + defvar mx = mti.LMul.MX; + defvar WriteVMSFSV_MX = !cast("WriteVMSFSV_" # mx); + defvar ReadVMSFSV_MX = !cast("ReadVMSFSV_" # mx); + let VLMul = mti.LMul.value in { + def "_M_" # mti.BX : XVPseudoUnaryNoMask, + Sched<[WriteVMSFSV_MX, ReadVMSFSV_MX, ReadVMask]>; + def "_M_" # mti.BX # "_MASK" : XVPseudoUnaryMask, + Sched<[WriteVMSFSV_MX, ReadVMSFSV_MX, ReadVMask]>; + } + } +} + //===----------------------------------------------------------------------===// // Helpers to define the intrinsic patterns for the XTHeadVector extension. //===----------------------------------------------------------------------===// @@ -2995,6 +3051,52 @@ multiclass XVPatNullaryM { GPR:$vl, mti.Log2SEW)>; } +multiclass XVPatUnaryS_M { + foreach mti = AllXMasks in { + def : Pat<(XLenVT (!cast(intrinsic_name) + (mti.Mask VR:$rs1), VLOpFrag)), + (!cast(inst#"_M_"#mti.BX) $rs1, + GPR:$vl, mti.Log2SEW)>; + def : Pat<(XLenVT (!cast(intrinsic_name # "_mask") + (mti.Mask VR:$rs1), (mti.Mask V0), VLOpFrag)), + (!cast(inst#"_M_"#mti.BX#"_MASK") $rs1, + (mti.Mask V0), GPR:$vl, mti.Log2SEW)>; + } +} + +class XVPatMaskUnaryNoMask : + Pat<(mti.Mask (!cast(intrinsic_name) + (mti.Mask VR:$rs2), + VLOpFrag)), + (!cast(inst#"_M_"#mti.BX) + (mti.Mask (IMPLICIT_DEF)), + (mti.Mask VR:$rs2), + GPR:$vl, mti.Log2SEW)>; + +class XVPatMaskUnaryMask : + Pat<(mti.Mask (!cast(intrinsic_name#"_mask") + (mti.Mask VR:$merge), + (mti.Mask VR:$rs2), + (mti.Mask V0), + VLOpFrag)), + (!cast(inst#"_M_"#mti.BX#"_MASK") + (mti.Mask VR:$merge), + (mti.Mask VR:$rs2), + (mti.Mask V0), GPR:$vl, mti.Log2SEW)>; + +multiclass XVPatUnaryM_M { + foreach mti = AllXMasks in { + def : XVPatMaskUnaryNoMask; + def : XVPatMaskUnaryMask; + } +} + multiclass XVPatCompare_VI { foreach vti = AllIntegerXVectors in { @@ -3911,4 +4013,25 @@ let Predicates = [HasVendorXTHeadV] in { defm : XVPatNullaryM<"int_riscv_th_vmset", "PseudoTH_VMSET">; } +//===----------------------------------------------------------------------===// +// 16.2. Vector mask population count vpopc +// 16.3. vfirst find-first-set mask bit +// 16.4. vmsbf.m set-before-first mask bit +// 16.5. vmsif.m set-including-first mask bit +// 16.6. vmsof.m set-only-first mask bit +//===----------------------------------------------------------------------===// + +defm PseudoTH_VMPOPC: XVPseudoVPOP_M; +defm PseudoTH_VMFIRST: XVPseudoV1ST_M; +defm PseudoTH_VMSBF: XVPseudoVSFS_M; +defm PseudoTH_VMSIF: XVPseudoVSFS_M; +defm PseudoTH_VMSOF: XVPseudoVSFS_M; + +// Patterns +defm : XVPatUnaryS_M<"int_riscv_th_vmpopc", "PseudoTH_VMPOPC">; +defm : XVPatUnaryS_M<"int_riscv_th_vmfirst", "PseudoTH_VMFIRST">; +defm : XVPatUnaryM_M<"int_riscv_th_vmsbf", "PseudoTH_VMSBF">; +defm : XVPatUnaryM_M<"int_riscv_th_vmsif", "PseudoTH_VMSIF">; +defm : XVPatUnaryM_M<"int_riscv_th_vmsof", "PseudoTH_VMSOF">; + include "RISCVInstrInfoXTHeadVVLPatterns.td" diff --git a/llvm/test/CodeGen/RISCV/rvv0p71/vmfirst.ll b/llvm/test/CodeGen/RISCV/rvv0p71/vmfirst.ll new file mode 100644 index 00000000000000..f40d290161321e --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv0p71/vmfirst.ll @@ -0,0 +1,229 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s + +declare iXLen @llvm.riscv.th.vmfirst.iXLen.nxv8i1( + , + iXLen); + +define iXLen @intrinsic_vmfirst_m_nxv8i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_m_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmfirst.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.iXLen.nxv8i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv8i1( + , + , + iXLen); + +define iXLen @intrinsic_vmfirst_mask_m_nxv8i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_mask_m_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmfirst.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv8i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmfirst.iXLen.nxv16i1( + , + iXLen); + +define iXLen @intrinsic_vmfirst_m_nxv16i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_m_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmfirst.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.iXLen.nxv16i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv16i1( + , + , + iXLen); + +define iXLen @intrinsic_vmfirst_mask_m_nxv16i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_mask_m_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmfirst.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv16i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmfirst.iXLen.nxv32i1( + , + iXLen); + +define iXLen @intrinsic_vmfirst_m_nxv32i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_m_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmfirst.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.iXLen.nxv32i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv32i1( + , + , + iXLen); + +define iXLen @intrinsic_vmfirst_mask_m_nxv32i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_mask_m_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmfirst.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv32i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmfirst.iXLen.nxv64i1( + , + iXLen); + +define iXLen @intrinsic_vmfirst_m_nxv64i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_m_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmfirst.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.iXLen.nxv64i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv64i1( + , + , + iXLen); + +define iXLen @intrinsic_vmfirst_mask_m_nxv64i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmfirst_mask_m_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmfirst.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmfirst.mask.iXLen.nxv64i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} diff --git a/llvm/test/CodeGen/RISCV/rvv0p71/vmpopc.ll b/llvm/test/CodeGen/RISCV/rvv0p71/vmpopc.ll new file mode 100644 index 00000000000000..f4f386f9496844 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv0p71/vmpopc.ll @@ -0,0 +1,229 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s + +declare iXLen @llvm.riscv.th.vmpopc.iXLen.nxv8i1( + , + iXLen); + +define iXLen @intrinsic_vmpopc_m_nxv8i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_m_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmpopc.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.iXLen.nxv8i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv8i1( + , + , + iXLen); + +define iXLen @intrinsic_vmpopc_mask_m_nxv8i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_mask_m_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmpopc.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv8i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmpopc.iXLen.nxv16i1( + , + iXLen); + +define iXLen @intrinsic_vmpopc_m_nxv16i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_m_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmpopc.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.iXLen.nxv16i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv16i1( + , + , + iXLen); + +define iXLen @intrinsic_vmpopc_mask_m_nxv16i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_mask_m_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmpopc.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv16i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmpopc.iXLen.nxv32i1( + , + iXLen); + +define iXLen @intrinsic_vmpopc_m_nxv32i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_m_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmpopc.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.iXLen.nxv32i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv32i1( + , + , + iXLen); + +define iXLen @intrinsic_vmpopc_mask_m_nxv32i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_mask_m_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmpopc.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv32i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmpopc.iXLen.nxv64i1( + , + iXLen); + +define iXLen @intrinsic_vmpopc_m_nxv64i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_m_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmpopc.m a0, v0 +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.iXLen.nxv64i1( + %0, + iXLen %1) + + ret iXLen %a +} + +declare iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv64i1( + , + , + iXLen); + +define iXLen @intrinsic_vmpopc_mask_m_nxv64i1( %0, %1, iXLen %2) nounwind { +; CHECK-LABEL: intrinsic_vmpopc_mask_m_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v9, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmpopc.m a0, v9, v0.t +; CHECK-NEXT: ret +entry: + %a = call iXLen @llvm.riscv.th.vmpopc.mask.iXLen.nxv64i1( + %0, + %1, + iXLen %2) + + ret iXLen %a +} diff --git a/llvm/test/CodeGen/RISCV/rvv0p71/vmsbf.ll b/llvm/test/CodeGen/RISCV/rvv0p71/vmsbf.ll new file mode 100644 index 00000000000000..0a934fd1532db4 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv0p71/vmsbf.ll @@ -0,0 +1,277 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s + +declare @llvm.riscv.th.vmsbf.nxv8i1( + , + iXLen); + +define @intrinsic_vmsbf_m_nxv8i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_m_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmsbf.m v8, v0 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.nxv8i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsbf.mask.nxv8i1( + , + , + , + iXLen); + +define @intrinsic_vmsbf_mask_m_nxv8i1_nxv8i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_mask_m_nxv8i1_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmsbf.m v10, v8, v0.t +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.mask.nxv8i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsbf.nxv16i1( + , + iXLen); + +define @intrinsic_vmsbf_m_nxv16i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_m_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmsbf.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.nxv16i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsbf.mask.nxv16i1( + , + , + , + iXLen); + +define @intrinsic_vmsbf_mask_m_nxv16i1_nxv16i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_mask_m_nxv16i1_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmsbf.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.mask.nxv16i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsbf.nxv32i1( + , + iXLen); + +define @intrinsic_vmsbf_m_nxv32i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_m_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmsbf.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.nxv32i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsbf.mask.nxv32i1( + , + , + , + iXLen); + +define @intrinsic_vmsbf_mask_m_nxv32i1_nxv32i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_mask_m_nxv32i1_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmsbf.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.mask.nxv32i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsbf.nxv64i1( + , + iXLen); + +define @intrinsic_vmsbf_m_nxv64i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_m_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmsbf.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.nxv64i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsbf.mask.nxv64i1( + , + , + , + iXLen); + +define @intrinsic_vmsbf_mask_m_nxv64i1_nxv64i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsbf_mask_m_nxv64i1_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmsbf.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsbf.mask.nxv64i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} diff --git a/llvm/test/CodeGen/RISCV/rvv0p71/vmsif.ll b/llvm/test/CodeGen/RISCV/rvv0p71/vmsif.ll new file mode 100644 index 00000000000000..56e6829bfc8a2d --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv0p71/vmsif.ll @@ -0,0 +1,277 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s + +declare @llvm.riscv.th.vmsif.nxv8i1( + , + iXLen); + +define @intrinsic_vmsif_m_nxv8i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsif_m_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmsif.m v8, v0 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.nxv8i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsif.mask.nxv8i1( + , + , + , + iXLen); + +define @intrinsic_vmsif_mask_m_nxv8i1_nxv8i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsif_mask_m_nxv8i1_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmsif.m v10, v8, v0.t +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.mask.nxv8i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsif.nxv16i1( + , + iXLen); + +define @intrinsic_vmsif_m_nxv16i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsif_m_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmsif.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.nxv16i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsif.mask.nxv16i1( + , + , + , + iXLen); + +define @intrinsic_vmsif_mask_m_nxv16i1_nxv16i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsif_mask_m_nxv16i1_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmsif.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.mask.nxv16i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsif.nxv32i1( + , + iXLen); + +define @intrinsic_vmsif_m_nxv32i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsif_m_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmsif.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.nxv32i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsif.mask.nxv32i1( + , + , + , + iXLen); + +define @intrinsic_vmsif_mask_m_nxv32i1_nxv32i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsif_mask_m_nxv32i1_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmsif.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.mask.nxv32i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsif.nxv64i1( + , + iXLen); + +define @intrinsic_vmsif_m_nxv64i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsif_m_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmsif.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.nxv64i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsif.mask.nxv64i1( + , + , + , + iXLen); + +define @intrinsic_vmsif_mask_m_nxv64i1_nxv64i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsif_mask_m_nxv64i1_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmsif.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsif.mask.nxv64i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} diff --git a/llvm/test/CodeGen/RISCV/rvv0p71/vmsof.ll b/llvm/test/CodeGen/RISCV/rvv0p71/vmsof.ll new file mode 100644 index 00000000000000..52b4711c897d04 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv0p71/vmsof.ll @@ -0,0 +1,277 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s +; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+xtheadvector \ +; RUN: -verify-machineinstrs | FileCheck %s + +declare @llvm.riscv.th.vmsof.nxv8i1( + , + iXLen); + +define @intrinsic_vmsof_m_nxv8i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsof_m_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmsof.m v8, v0 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.nxv8i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsof.mask.nxv8i1( + , + , + , + iXLen); + +define @intrinsic_vmsof_mask_m_nxv8i1_nxv8i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsof_mask_m_nxv8i1_nxv8i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m1, d1 +; CHECK-NEXT: th.vmsof.m v10, v8, v0.t +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.mask.nxv8i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsof.nxv16i1( + , + iXLen); + +define @intrinsic_vmsof_m_nxv16i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsof_m_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmsof.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.nxv16i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsof.mask.nxv16i1( + , + , + , + iXLen); + +define @intrinsic_vmsof_mask_m_nxv16i1_nxv16i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsof_mask_m_nxv16i1_nxv16i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m2, d1 +; CHECK-NEXT: th.vmsof.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.mask.nxv16i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsof.nxv32i1( + , + iXLen); + +define @intrinsic_vmsof_m_nxv32i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsof_m_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmsof.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.nxv32i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsof.mask.nxv32i1( + , + , + , + iXLen); + +define @intrinsic_vmsof_mask_m_nxv32i1_nxv32i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsof_mask_m_nxv32i1_nxv32i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m4, d1 +; CHECK-NEXT: th.vmsof.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.mask.nxv32i1( + %0, + %1, + %2, + iXLen %3) + ret %a +} + +declare @llvm.riscv.th.vmsof.nxv64i1( + , + iXLen); + +define @intrinsic_vmsof_m_nxv64i1( %0, iXLen %1) nounwind { +; CHECK-LABEL: intrinsic_vmsof_m_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmsof.m v8, v0 +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v8 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.nxv64i1( + %0, + iXLen %1) + ret %a +} + +declare @llvm.riscv.th.vmsof.mask.nxv64i1( + , + , + , + iXLen); + +define @intrinsic_vmsof_mask_m_nxv64i1_nxv64i1( %0, %1, %2, iXLen %3) nounwind { +; CHECK-LABEL: intrinsic_vmsof_mask_m_nxv64i1_nxv64i1: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v10, v0 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: csrr a1, vl +; CHECK-NEXT: csrr a2, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v9 +; CHECK-NEXT: th.vsetvl zero, a1, a2 +; CHECK-NEXT: th.vsetvli zero, a0, e8, m8, d1 +; CHECK-NEXT: th.vmsof.m v10, v8, v0.t +; CHECK-NEXT: csrr a0, vl +; CHECK-NEXT: csrr a1, vtype +; CHECK-NEXT: th.vsetvli zero, zero, e8, m1, d1 +; CHECK-NEXT: th.vmv.v.v v0, v10 +; CHECK-NEXT: th.vsetvl zero, a0, a1 +; CHECK-NEXT: ret +entry: + %a = call @llvm.riscv.th.vmsof.mask.nxv64i1( + %0, + %1, + %2, + iXLen %3) + ret %a +}