diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -14907,6 +14907,8 @@ This function returns the same values as the libm ``rint`` functions would, and handles error conditions in the same way. +.. _int_nearbyint: + '``llvm.nearbyint.*``' Intrinsic ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -21837,6 +21839,53 @@ %t = call <4 x float> @llvm.rint.v4f32(<4 x float> %a) %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison +.. _int_vp_nearbyint: + +'``llvm.vp.nearbyint.*``' Intrinsics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" +This is an overloaded intrinsic. + +:: + + declare <16 x float> @llvm.vp.nearbyint.v16f32 (<16 x float> , <16 x i1> , i32 ) + declare @llvm.vp.nearbyint.nxv4f32 ( , , i32 ) + declare <256 x double> @llvm.vp.nearbyint.v256f64 (<256 x double> , <256 x i1> , i32 ) + +Overview: +""""""""" + +Predicated floating-point nearbyint of a vector of floating-point values. + + +Arguments: +"""""""""" + +The first operand and the result have the same vector of floating-point type. +The second operand is the vector mask and has the same number of elements as the +result vector type. The third operand is the explicit vector length of the +operation. + +Semantics: +"""""""""" + +The '``llvm.vp.nearbyint``' intrinsic performs floating-point nearbyint +(:ref:`nearbyint `) of the first vector operand on each enabled lane. +The result on disabled lanes is a :ref:`poison value `. + +Examples: +""""""""" + +.. code-block:: llvm + + %r = call <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float> %a, <4 x i1> %mask, i32 %evl) + ;; For all lanes below %evl, %r is lane-wise equivalent to %also.r + + %t = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %a) + %also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> poison + .. _int_vp_round: '``llvm.vp.round.*``' Intrinsics diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -1648,6 +1648,10 @@ [ LLVMMatchType<0>, LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, llvm_i32_ty]>; + def int_vp_nearbyint : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], + [ LLVMMatchType<0>, + LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, + llvm_i32_ty]>; // Casts def int_vp_trunc : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ], diff --git a/llvm/include/llvm/IR/VPIntrinsics.def b/llvm/include/llvm/IR/VPIntrinsics.def --- a/llvm/include/llvm/IR/VPIntrinsics.def +++ b/llvm/include/llvm/IR/VPIntrinsics.def @@ -310,6 +310,10 @@ BEGIN_REGISTER_VP(vp_rint, 1, 2, VP_FRINT, -1) END_REGISTER_VP(vp_rint, VP_FRINT) +// llvm.vp.nearbyint(x,mask,vlen) +BEGIN_REGISTER_VP(vp_nearbyint, 1, 2, VP_FNEARBYINT, -1) +END_REGISTER_VP(vp_nearbyint, VP_FNEARBYINT) + ///// } Floating-Point Arithmetic ///// Type Casts { diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -1030,6 +1030,7 @@ case ISD::FLOG10: case ISD::FLOG2: case ISD::FNEARBYINT: + case ISD::VP_FNEARBYINT: case ISD::FNEG: case ISD::VP_FNEG: case ISD::FREEZE: case ISD::ARITH_FENCE: @@ -4095,6 +4096,7 @@ case ISD::VP_FCEIL: case ISD::VP_FFLOOR: case ISD::VP_FRINT: + case ISD::VP_FNEARBYINT: case ISD::VP_FROUND: case ISD::VP_FROUNDEVEN: case ISD::VP_FROUNDTOZERO: diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h --- a/llvm/lib/Target/RISCV/RISCVISelLowering.h +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h @@ -234,6 +234,7 @@ VFCVT_RTZ_X_F_VL, VFCVT_RTZ_XU_F_VL, VFCVT_X_F_VL, + VFROUND_NOEXCEPT_VL, VFCVT_RM_X_F_VL, // Has a rounding mode operand. SINT_TO_FP_VL, UINT_TO_FP_VL, diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -485,7 +485,7 @@ ISD::VP_SQRT, ISD::VP_FMINNUM, ISD::VP_FMAXNUM, ISD::VP_FCEIL, ISD::VP_FFLOOR, ISD::VP_FROUND, ISD::VP_FROUNDEVEN, ISD::VP_FCOPYSIGN, ISD::VP_FROUNDTOZERO, - ISD::VP_FRINT}; + ISD::VP_FRINT, ISD::VP_FNEARBYINT}; static const unsigned IntegerVecReduceOps[] = { ISD::VECREDUCE_ADD, ISD::VECREDUCE_AND, ISD::VECREDUCE_OR, @@ -2005,9 +2005,9 @@ } // Expand vector FTRUNC, FCEIL, FFLOOR, FROUND, VP_FCEIL, VP_FFLOOR, VP_FROUND -// VP_FROUNDEVEN, VP_FROUNDTOZERO and VP_FRINT by converting to the integer -// domain and back. Taking care to avoid converting values that are nan or -// already correct. +// VP_FROUNDEVEN, VP_FROUNDTOZERO, VP_FRINT and VP_FNEARBYINT by converting to +// the integer domain and back. Taking care to avoid converting values that are +// nan or already correct. static SDValue lowerVectorFTRUNC_FCEIL_FFLOOR_FROUND(SDValue Op, SelectionDAG &DAG, const RISCVSubtarget &Subtarget) { @@ -2088,10 +2088,16 @@ case ISD::VP_FRINT: Truncated = DAG.getNode(RISCVISD::VFCVT_X_F_VL, DL, IntVT, Src, Mask, VL); break; + case ISD::VP_FNEARBYINT: + Truncated = DAG.getNode(RISCVISD::VFROUND_NOEXCEPT_VL, DL, ContainerVT, Src, + Mask, VL); + break; } - Truncated = DAG.getNode(RISCVISD::SINT_TO_FP_VL, DL, ContainerVT, Truncated, - Mask, VL); + // VFROUND_NOEXCEPT_VL includes SINT_TO_FP_VL. + if (Op.getOpcode() != ISD::VP_FNEARBYINT) + Truncated = DAG.getNode(RISCVISD::SINT_TO_FP_VL, DL, ContainerVT, Truncated, + Mask, VL); // Restore the original sign so that -0.0 is preserved. Truncated = DAG.getNode(RISCVISD::FCOPYSIGN_VL, DL, ContainerVT, Truncated, @@ -4095,6 +4101,7 @@ case ISD::VP_FCEIL: case ISD::VP_FFLOOR: case ISD::VP_FRINT: + case ISD::VP_FNEARBYINT: case ISD::VP_FROUND: case ISD::VP_FROUNDEVEN: case ISD::VP_FROUNDTOZERO: @@ -10782,6 +10789,54 @@ return BB; } +static MachineBasicBlock *emitVFROUND_NOEXCEPT_MASK(MachineInstr &MI, + MachineBasicBlock *BB, + unsigned CVTXOpc, + unsigned CVTFOpc) { + DebugLoc DL = MI.getDebugLoc(); + + const TargetInstrInfo &TII = *BB->getParent()->getSubtarget().getInstrInfo(); + + MachineRegisterInfo &MRI = BB->getParent()->getRegInfo(); + Register SavedFFLAGS = MRI.createVirtualRegister(&RISCV::GPRRegClass); + + // Save the old value of FFLAGS. + BuildMI(*BB, MI, DL, TII.get(RISCV::ReadFFLAGS), SavedFFLAGS); + + assert(MI.getNumOperands() == 7); + + // Emit a VFCVT_X_F + const TargetRegisterInfo *TRI = + BB->getParent()->getSubtarget().getRegisterInfo(); + const TargetRegisterClass *RC = MI.getRegClassConstraint(0, &TII, TRI); + Register Tmp = MRI.createVirtualRegister(RC); + BuildMI(*BB, MI, DL, TII.get(CVTXOpc), Tmp) + .add(MI.getOperand(1)) + .add(MI.getOperand(2)) + .add(MI.getOperand(3)) + .add(MI.getOperand(4)) + .add(MI.getOperand(5)) + .add(MI.getOperand(6)); + + // Emit a VFCVT_F_X + BuildMI(*BB, MI, DL, TII.get(CVTFOpc)) + .add(MI.getOperand(0)) + .add(MI.getOperand(1)) + .addReg(Tmp) + .add(MI.getOperand(3)) + .add(MI.getOperand(4)) + .add(MI.getOperand(5)) + .add(MI.getOperand(6)); + + // Restore FFLAGS. + BuildMI(*BB, MI, DL, TII.get(RISCV::WriteFFLAGS)) + .addReg(SavedFFLAGS, RegState::Kill); + + // Erase the pseudoinstruction. + MI.eraseFromParent(); + return BB; +} + static MachineBasicBlock *emitFROUND(MachineInstr &MI, MachineBasicBlock *MBB, const RISCVSubtarget &Subtarget) { unsigned CmpOpc, F2IOpc, I2FOpc, FSGNJOpc, FSGNJXOpc; @@ -10932,6 +10987,24 @@ return emitVFCVT_RM_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_MF2_MASK); case RISCV::PseudoVFCVT_RM_X_F_V_MF4_MASK: return emitVFCVT_RM_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_MF4_MASK); + case RISCV::PseudoVFROUND_NOEXCEPT_V_M1_MASK: + return emitVFROUND_NOEXCEPT_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_M1_MASK, + RISCV::PseudoVFCVT_F_X_V_M1_MASK); + case RISCV::PseudoVFROUND_NOEXCEPT_V_M2_MASK: + return emitVFROUND_NOEXCEPT_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_M2_MASK, + RISCV::PseudoVFCVT_F_X_V_M2_MASK); + case RISCV::PseudoVFROUND_NOEXCEPT_V_M4_MASK: + return emitVFROUND_NOEXCEPT_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_M4_MASK, + RISCV::PseudoVFCVT_F_X_V_M4_MASK); + case RISCV::PseudoVFROUND_NOEXCEPT_V_M8_MASK: + return emitVFROUND_NOEXCEPT_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_M8_MASK, + RISCV::PseudoVFCVT_F_X_V_M8_MASK); + case RISCV::PseudoVFROUND_NOEXCEPT_V_MF2_MASK: + return emitVFROUND_NOEXCEPT_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_MF2_MASK, + RISCV::PseudoVFCVT_F_X_V_MF2_MASK); + case RISCV::PseudoVFROUND_NOEXCEPT_V_MF4_MASK: + return emitVFROUND_NOEXCEPT_MASK(MI, BB, RISCV::PseudoVFCVT_X_F_V_MF4_MASK, + RISCV::PseudoVFCVT_F_X_V_MF4_MASK); case RISCV::PseudoFROUND_H: case RISCV::PseudoFROUND_S: case RISCV::PseudoFROUND_D: @@ -12484,6 +12557,7 @@ NODE_NAME_CASE(VFCVT_RTZ_XU_F_VL) NODE_NAME_CASE(VFCVT_RM_X_F_VL) NODE_NAME_CASE(VFCVT_X_F_VL) + NODE_NAME_CASE(VFROUND_NOEXCEPT_VL) NODE_NAME_CASE(SINT_TO_FP_VL) NODE_NAME_CASE(UINT_TO_FP_VL) NODE_NAME_CASE(FP_EXTEND_VL) diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -1032,6 +1032,22 @@ let UsesMaskPolicy = 1; } +class VPseudoUnaryMaskTA_NoExcept : + Pseudo<(outs GetVRegNoV0.R:$rd), + (ins GetVRegNoV0.R:$merge, OpClass:$rs2, VMaskOp:$vm, + AVL:$vl, ixlenimm:$sew, ixlenimm:$policy), []> { + let mayLoad = 0; + let mayStore = 0; + let hasSideEffects = 0; + let Constraints = Join<[Constraint, "$rd = $merge"], ",">.ret; + let HasVLOp = 1; + let HasSEWOp = 1; + let HasMergeOp = 1; + let HasVecPolicyOp = 1; + let UsesMaskPolicy = 1; + let usesCustomInserter = 1; +} + class VPseudoUnaryMaskTA_FRM : Pseudo<(outs GetVRegNoV0.R:$rd), (ins GetVRegNoV0.R:$merge, OpClass:$rs2, @@ -3064,6 +3080,15 @@ } } +multiclass VPseudoConversionNoExcept { + let VLMul = MInfo.value in { + def "_" # MInfo.MX # "_MASK" : VPseudoUnaryMaskTA_NoExcept; + } +} + multiclass VPseudoVCVTI_V { foreach m = MxListF in defm _V : VPseudoConversion, @@ -3076,6 +3101,12 @@ Sched<[WriteVFCvtFToIV, ReadVFCvtFToIV, ReadVMask]>; } +multiclass VPseudoVFROUND_NOEXCEPT_V { + foreach m = MxListF in + defm _V : VPseudoConversionNoExcept, + Sched<[WriteVFCvtFToIV, ReadVFCvtFToIV, ReadVMask]>; +} + multiclass VPseudoVCVTF_V { foreach m = MxListF in defm _V : VPseudoConversion, @@ -5154,6 +5185,7 @@ defm PseudoVFCVT_RTZ_XU_F : VPseudoVCVTI_V; defm PseudoVFCVT_RTZ_X_F : VPseudoVCVTI_V; defm PseudoVFCVT_RM_X_F : VPseudoVCVTI_RM_V; +defm PseudoVFROUND_NOEXCEPT : VPseudoVFROUND_NOEXCEPT_V; let Uses = [FRM] in { defm PseudoVFCVT_F_XU : VPseudoVCVTF_V; defm PseudoVFCVT_F_X : VPseudoVCVTF_V; diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td @@ -154,6 +154,7 @@ def riscv_vfcvt_rm_x_f_vl : SDNode<"RISCVISD::VFCVT_RM_X_F_VL", SDT_RISCVVecCvtX2FOp_VL>; def riscv_vfcvt_x_f_vl : SDNode<"RISCVISD::VFCVT_X_F_VL", SDT_RISCVFP2IOp_VL>; +def riscv_vfround_noexcept_vl: SDNode<"RISCVISD::VFROUND_NOEXCEPT_VL", SDT_RISCVFPUnOp_VL>; def riscv_setcc_vl : SDNode<"RISCVISD::SETCC_VL", SDTypeProfile<1, 6, [SDTCVecEltisVT<0, i1>, @@ -1626,6 +1627,13 @@ vti.RegClass:$merge, vti.RegClass:$rs1, vti.ScalarRegClass:$rs2, (vti.Mask V0), GPR:$vl, vti.Log2SEW, TAIL_AGNOSTIC)>; + + // Rounding without exception to implement nearbyint. + def : Pat<(riscv_vfround_noexcept_vl (vti.Vector vti.RegClass:$rs1), + (vti.Mask V0), VLOpFrag), + (!cast("PseudoVFROUND_NOEXCEPT_V_" # vti.LMul.MX #"_MASK") + (vti.Vector (IMPLICIT_DEF)), vti.RegClass:$rs1, + (vti.Mask V0), GPR:$vl, vti.Log2SEW, TA_MA)>; } foreach fvti = AllFloatVectors in { diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp @@ -537,6 +537,14 @@ return Cost * LT.first; break; } + case Intrinsic::vp_nearbyint: { + // More one read and one write for fflags than vp_rint. + unsigned Cost = 7; + auto LT = getTypeLegalizationCost(RetTy); + if (TLI->isOperationCustom(ISD::VP_FRINT, LT.second)) + return Cost * LT.first; + break; + } } if (ST->hasVInstructions() && RetTy->isVectorTy()) { diff --git a/llvm/test/Analysis/CostModel/RISCV/fround.ll b/llvm/test/Analysis/CostModel/RISCV/fround.ll --- a/llvm/test/Analysis/CostModel/RISCV/fround.ll +++ b/llvm/test/Analysis/CostModel/RISCV/fround.ll @@ -357,6 +357,47 @@ ret void } +define void @vp_nearbyint() { +; CHECK-LABEL: 'vp_nearbyint' +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %1 = call <2 x float> @llvm.vp.nearbyint.v2f32(<2 x float> undef, <2 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %2 = call <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float> undef, <4 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %3 = call <8 x float> @llvm.vp.nearbyint.v8f32(<8 x float> undef, <8 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %4 = call <16 x float> @llvm.vp.nearbyint.v16f32(<16 x float> undef, <16 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %5 = call @llvm.vp.nearbyint.nxv1f32( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %6 = call @llvm.vp.nearbyint.nxv2f32( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %7 = call @llvm.vp.nearbyint.nxv4f32( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %8 = call @llvm.vp.nearbyint.nxv8f32( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %9 = call @llvm.vp.nearbyint.nxv16f32( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %10 = call <2 x double> @llvm.vp.nearbyint.v2f64(<2 x double> undef, <2 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %11 = call <4 x double> @llvm.vp.nearbyint.v4f64(<4 x double> undef, <4 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %12 = call <8 x double> @llvm.vp.nearbyint.v8f64(<8 x double> undef, <8 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %13 = call <16 x double> @llvm.vp.nearbyint.v16f64(<16 x double> undef, <16 x i1> undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %14 = call @llvm.vp.nearbyint.nxv1f64( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %15 = call @llvm.vp.nearbyint.nxv2f64( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %16 = call @llvm.vp.nearbyint.nxv4f64( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 7 for instruction: %17 = call @llvm.vp.nearbyint.nxv8f64( undef, undef, i32 undef) +; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void +; + call <2 x float> @llvm.vp.nearbyint.v2f32(<2 x float> undef, <2 x i1> undef, i32 undef) + call <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float> undef, <4 x i1> undef, i32 undef) + call <8 x float> @llvm.vp.nearbyint.v8f32(<8 x float> undef, <8 x i1> undef, i32 undef) + call <16 x float> @llvm.vp.nearbyint.v16f32(<16 x float> undef, <16 x i1> undef, i32 undef) + call @llvm.vp.nearbyint.nvx1f32( undef, undef, i32 undef) + call @llvm.vp.nearbyint.nvx2f32( undef, undef, i32 undef) + call @llvm.vp.nearbyint.nvx4f32( undef, undef, i32 undef) + call @llvm.vp.nearbyint.nvx8f32( undef, undef, i32 undef) + call @llvm.vp.nearbyint.nvx16f32( undef, undef, i32 undef) + call <2 x double> @llvm.vp.nearbyint.v2f64(<2 x double> undef, <2 x i1> undef, i32 undef) + call <4 x double> @llvm.vp.nearbyint.v4f64(<4 x double> undef, <4 x i1> undef, i32 undef) + call <8 x double> @llvm.vp.nearbyint.v8f64(<8 x double> undef, <8 x i1> undef, i32 undef) + call <16 x double> @llvm.vp.nearbyint.v16f64(<16 x double> undef, <16 x i1> undef, i32 undef) + call @llvm.vp.nearbyint.nvx1f64( undef, undef, i32 undef) + call @llvm.vp.nearbyint.nvx2f64( undef, undef, i32 undef) + call @llvm.vp.nearbyint.nvx5f64( undef, undef, i32 undef) + call @llvm.vp.nearbyint.nvx8f64( undef, undef, i32 undef) + ret void +} + declare float @llvm.floor.f32(float) declare <2 x float> @llvm.floor.v2f32(<2 x float>) declare <4 x float> @llvm.floor.v4f32(<4 x float>) @@ -515,3 +556,22 @@ declare @llvm.vp.rint.nvx2f64(, , i32) declare @llvm.vp.rint.nvx5f64(, , i32) declare @llvm.vp.rint.nvx8f64(, , i32) + +declare <2 x float> @llvm.vp.nearbyint.v2f32(<2 x float>, <2 x i1>, i32) +declare <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float>, <4 x i1>, i32) +declare <8 x float> @llvm.vp.nearbyint.v8f32(<8 x float>, <8 x i1>, i32) +declare <16 x float> @llvm.vp.nearbyint.v16f32(<16 x float>, <16 x i1>, i32) +declare @llvm.vp.nearbyint.nvx1f32(, , i32) +declare @llvm.vp.nearbyint.nvx2f32(, , i32) +declare @llvm.vp.nearbyint.nvx4f32(, , i32) +declare @llvm.vp.nearbyint.nvx8f32(, , i32) +declare @llvm.vp.nearbyint.nvx16f32(, , i32) +declare double @llvm.vp.nearbyint.f64(double) +declare <2 x double> @llvm.vp.nearbyint.v2f64(<2 x double>, <2 x i1>, i32) +declare <4 x double> @llvm.vp.nearbyint.v4f64(<4 x double>, <4 x i1>, i32) +declare <8 x double> @llvm.vp.nearbyint.v8f64(<8 x double>, <8 x i1>, i32) +declare <16 x double> @llvm.vp.nearbyint.v16f64(<16 x double>, <16 x i1>, i32) +declare @llvm.vp.nearbyint.nvx1f64(, , i32) +declare @llvm.vp.nearbyint.nvx2f64(, , i32) +declare @llvm.vp.nearbyint.nvx5f64(, , i32) +declare @llvm.vp.nearbyint.nvx8f64(, , i32) diff --git a/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-nearbyint-vp.ll b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-nearbyint-vp.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/fixed-vectors-nearbyint-vp.ll @@ -0,0 +1,759 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+experimental-zvfh,+v -target-abi=ilp32d -riscv-v-vector-bits-min=128 \ +; RUN: -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+experimental-zvfh,+v -target-abi=lp64d -riscv-v-vector-bits-min=128 \ +; RUN: -verify-machineinstrs < %s | FileCheck %s + +declare <2 x half> @llvm.vp.nearbyint.v2f16(<2 x half>, <2 x i1>, i32) + +define <2 x half> @vp_nearbyint_v2f16(<2 x half> %va, <2 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI0_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI0_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call <2 x half> @llvm.vp.nearbyint.v2f16(<2 x half> %va, <2 x i1> %m, i32 %evl) + ret <2 x half> %v +} + +define <2 x half> @vp_nearbyint_v2f16_unmasked(<2 x half> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v2f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI1_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI1_0)(a1) +; CHECK-NEXT: vsetivli zero, 2, e8, mf8, ta, ma +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <2 x i1> poison, i1 true, i32 0 + %m = shufflevector <2 x i1> %head, <2 x i1> poison, <2 x i32> zeroinitializer + %v = call <2 x half> @llvm.vp.nearbyint.v2f16(<2 x half> %va, <2 x i1> %m, i32 %evl) + ret <2 x half> %v +} + +declare <4 x half> @llvm.vp.nearbyint.v4f16(<4 x half>, <4 x i1>, i32) + +define <4 x half> @vp_nearbyint_v4f16(<4 x half> %va, <4 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI2_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI2_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call <4 x half> @llvm.vp.nearbyint.v4f16(<4 x half> %va, <4 x i1> %m, i32 %evl) + ret <4 x half> %v +} + +define <4 x half> @vp_nearbyint_v4f16_unmasked(<4 x half> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v4f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI3_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI3_0)(a1) +; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <4 x i1> poison, i1 true, i32 0 + %m = shufflevector <4 x i1> %head, <4 x i1> poison, <4 x i32> zeroinitializer + %v = call <4 x half> @llvm.vp.nearbyint.v4f16(<4 x half> %va, <4 x i1> %m, i32 %evl) + ret <4 x half> %v +} + +declare <8 x half> @llvm.vp.nearbyint.v8f16(<8 x half>, <8 x i1>, i32) + +define <8 x half> @vp_nearbyint_v8f16(<8 x half> %va, <8 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI4_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI4_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call <8 x half> @llvm.vp.nearbyint.v8f16(<8 x half> %va, <8 x i1> %m, i32 %evl) + ret <8 x half> %v +} + +define <8 x half> @vp_nearbyint_v8f16_unmasked(<8 x half> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v8f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI5_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI5_0)(a1) +; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <8 x i1> poison, i1 true, i32 0 + %m = shufflevector <8 x i1> %head, <8 x i1> poison, <8 x i32> zeroinitializer + %v = call <8 x half> @llvm.vp.nearbyint.v8f16(<8 x half> %va, <8 x i1> %m, i32 %evl) + ret <8 x half> %v +} + +declare <16 x half> @llvm.vp.nearbyint.v16f16(<16 x half>, <16 x i1>, i32) + +define <16 x half> @vp_nearbyint_v16f16(<16 x half> %va, <16 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v10, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI6_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI6_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %v = call <16 x half> @llvm.vp.nearbyint.v16f16(<16 x half> %va, <16 x i1> %m, i32 %evl) + ret <16 x half> %v +} + +define <16 x half> @vp_nearbyint_v16f16_unmasked(<16 x half> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v16f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI7_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI7_0)(a1) +; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma +; CHECK-NEXT: vmset.m v10 +; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <16 x i1> poison, i1 true, i32 0 + %m = shufflevector <16 x i1> %head, <16 x i1> poison, <16 x i32> zeroinitializer + %v = call <16 x half> @llvm.vp.nearbyint.v16f16(<16 x half> %va, <16 x i1> %m, i32 %evl) + ret <16 x half> %v +} + +declare <2 x float> @llvm.vp.nearbyint.v2f32(<2 x float>, <2 x i1>, i32) + +define <2 x float> @vp_nearbyint_v2f32(<2 x float> %va, <2 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI8_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI8_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call <2 x float> @llvm.vp.nearbyint.v2f32(<2 x float> %va, <2 x i1> %m, i32 %evl) + ret <2 x float> %v +} + +define <2 x float> @vp_nearbyint_v2f32_unmasked(<2 x float> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v2f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI9_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI9_0)(a1) +; CHECK-NEXT: vsetivli zero, 2, e8, mf8, ta, ma +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <2 x i1> poison, i1 true, i32 0 + %m = shufflevector <2 x i1> %head, <2 x i1> poison, <2 x i32> zeroinitializer + %v = call <2 x float> @llvm.vp.nearbyint.v2f32(<2 x float> %va, <2 x i1> %m, i32 %evl) + ret <2 x float> %v +} + +declare <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float>, <4 x i1>, i32) + +define <4 x float> @vp_nearbyint_v4f32(<4 x float> %va, <4 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI10_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI10_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float> %va, <4 x i1> %m, i32 %evl) + ret <4 x float> %v +} + +define <4 x float> @vp_nearbyint_v4f32_unmasked(<4 x float> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v4f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI11_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI11_0)(a1) +; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <4 x i1> poison, i1 true, i32 0 + %m = shufflevector <4 x i1> %head, <4 x i1> poison, <4 x i32> zeroinitializer + %v = call <4 x float> @llvm.vp.nearbyint.v4f32(<4 x float> %va, <4 x i1> %m, i32 %evl) + ret <4 x float> %v +} + +declare <8 x float> @llvm.vp.nearbyint.v8f32(<8 x float>, <8 x i1>, i32) + +define <8 x float> @vp_nearbyint_v8f32(<8 x float> %va, <8 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v10, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI12_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI12_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %v = call <8 x float> @llvm.vp.nearbyint.v8f32(<8 x float> %va, <8 x i1> %m, i32 %evl) + ret <8 x float> %v +} + +define <8 x float> @vp_nearbyint_v8f32_unmasked(<8 x float> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v8f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI13_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI13_0)(a1) +; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma +; CHECK-NEXT: vmset.m v10 +; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <8 x i1> poison, i1 true, i32 0 + %m = shufflevector <8 x i1> %head, <8 x i1> poison, <8 x i32> zeroinitializer + %v = call <8 x float> @llvm.vp.nearbyint.v8f32(<8 x float> %va, <8 x i1> %m, i32 %evl) + ret <8 x float> %v +} + +declare <16 x float> @llvm.vp.nearbyint.v16f32(<16 x float>, <16 x i1>, i32) + +define <16 x float> @vp_nearbyint_v16f32(<16 x float> %va, <16 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v12, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI14_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI14_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma +; CHECK-NEXT: vfabs.v v16, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu +; CHECK-NEXT: vmflt.vf v12, v16, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %v = call <16 x float> @llvm.vp.nearbyint.v16f32(<16 x float> %va, <16 x i1> %m, i32 %evl) + ret <16 x float> %v +} + +define <16 x float> @vp_nearbyint_v16f32_unmasked(<16 x float> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v16f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI15_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI15_0)(a1) +; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma +; CHECK-NEXT: vmset.m v12 +; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfabs.v v16, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu +; CHECK-NEXT: vmflt.vf v12, v16, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <16 x i1> poison, i1 true, i32 0 + %m = shufflevector <16 x i1> %head, <16 x i1> poison, <16 x i32> zeroinitializer + %v = call <16 x float> @llvm.vp.nearbyint.v16f32(<16 x float> %va, <16 x i1> %m, i32 %evl) + ret <16 x float> %v +} + +declare <2 x double> @llvm.vp.nearbyint.v2f64(<2 x double>, <2 x i1>, i32) + +define <2 x double> @vp_nearbyint_v2f64(<2 x double> %va, <2 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI16_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI16_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call <2 x double> @llvm.vp.nearbyint.v2f64(<2 x double> %va, <2 x i1> %m, i32 %evl) + ret <2 x double> %v +} + +define <2 x double> @vp_nearbyint_v2f64_unmasked(<2 x double> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v2f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI17_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI17_0)(a1) +; CHECK-NEXT: vsetivli zero, 2, e8, mf8, ta, ma +; CHECK-NEXT: vmset.m v0 +; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <2 x i1> poison, i1 true, i32 0 + %m = shufflevector <2 x i1> %head, <2 x i1> poison, <2 x i32> zeroinitializer + %v = call <2 x double> @llvm.vp.nearbyint.v2f64(<2 x double> %va, <2 x i1> %m, i32 %evl) + ret <2 x double> %v +} + +declare <4 x double> @llvm.vp.nearbyint.v4f64(<4 x double>, <4 x i1>, i32) + +define <4 x double> @vp_nearbyint_v4f64(<4 x double> %va, <4 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v10, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI18_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI18_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %v = call <4 x double> @llvm.vp.nearbyint.v4f64(<4 x double> %va, <4 x i1> %m, i32 %evl) + ret <4 x double> %v +} + +define <4 x double> @vp_nearbyint_v4f64_unmasked(<4 x double> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v4f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI19_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI19_0)(a1) +; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma +; CHECK-NEXT: vmset.m v10 +; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <4 x i1> poison, i1 true, i32 0 + %m = shufflevector <4 x i1> %head, <4 x i1> poison, <4 x i32> zeroinitializer + %v = call <4 x double> @llvm.vp.nearbyint.v4f64(<4 x double> %va, <4 x i1> %m, i32 %evl) + ret <4 x double> %v +} + +declare <8 x double> @llvm.vp.nearbyint.v8f64(<8 x double>, <8 x i1>, i32) + +define <8 x double> @vp_nearbyint_v8f64(<8 x double> %va, <8 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v12, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI20_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI20_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma +; CHECK-NEXT: vfabs.v v16, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu +; CHECK-NEXT: vmflt.vf v12, v16, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %v = call <8 x double> @llvm.vp.nearbyint.v8f64(<8 x double> %va, <8 x i1> %m, i32 %evl) + ret <8 x double> %v +} + +define <8 x double> @vp_nearbyint_v8f64_unmasked(<8 x double> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v8f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI21_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI21_0)(a1) +; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma +; CHECK-NEXT: vmset.m v12 +; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfabs.v v16, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu +; CHECK-NEXT: vmflt.vf v12, v16, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <8 x i1> poison, i1 true, i32 0 + %m = shufflevector <8 x i1> %head, <8 x i1> poison, <8 x i32> zeroinitializer + %v = call <8 x double> @llvm.vp.nearbyint.v8f64(<8 x double> %va, <8 x i1> %m, i32 %evl) + ret <8 x double> %v +} + +declare <15 x double> @llvm.vp.nearbyint.v15f64(<15 x double>, <15 x i1>, i32) + +define <15 x double> @vp_nearbyint_v15f64(<15 x double> %va, <15 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v15f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v16, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI22_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI22_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %v = call <15 x double> @llvm.vp.nearbyint.v15f64(<15 x double> %va, <15 x i1> %m, i32 %evl) + ret <15 x double> %v +} + +define <15 x double> @vp_nearbyint_v15f64_unmasked(<15 x double> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v15f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI23_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI23_0)(a1) +; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma +; CHECK-NEXT: vmset.m v16 +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <15 x i1> poison, i1 true, i32 0 + %m = shufflevector <15 x i1> %head, <15 x i1> poison, <15 x i32> zeroinitializer + %v = call <15 x double> @llvm.vp.nearbyint.v15f64(<15 x double> %va, <15 x i1> %m, i32 %evl) + ret <15 x double> %v +} + +declare <16 x double> @llvm.vp.nearbyint.v16f64(<16 x double>, <16 x i1>, i32) + +define <16 x double> @vp_nearbyint_v16f64(<16 x double> %va, <16 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v16f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v16, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI24_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI24_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %v = call <16 x double> @llvm.vp.nearbyint.v16f64(<16 x double> %va, <16 x i1> %m, i32 %evl) + ret <16 x double> %v +} + +define <16 x double> @vp_nearbyint_v16f64_unmasked(<16 x double> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v16f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI25_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI25_0)(a1) +; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma +; CHECK-NEXT: vmset.m v16 +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement <16 x i1> poison, i1 true, i32 0 + %m = shufflevector <16 x i1> %head, <16 x i1> poison, <16 x i32> zeroinitializer + %v = call <16 x double> @llvm.vp.nearbyint.v16f64(<16 x double> %va, <16 x i1> %m, i32 %evl) + ret <16 x double> %v +} + +declare <32 x double> @llvm.vp.nearbyint.v32f64(<32 x double>, <32 x i1>, i32) + +define <32 x double> @vp_nearbyint_v32f64(<32 x double> %va, <32 x i1> %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v32f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v2, v0 +; CHECK-NEXT: vsetivli zero, 2, e8, mf4, ta, ma +; CHECK-NEXT: li a2, 16 +; CHECK-NEXT: vslidedown.vi v1, v0, 2 +; CHECK-NEXT: mv a1, a0 +; CHECK-NEXT: bltu a0, a2, .LBB26_2 +; CHECK-NEXT: # %bb.1: +; CHECK-NEXT: li a1, 16 +; CHECK-NEXT: .LBB26_2: +; CHECK-NEXT: lui a2, %hi(.LCPI26_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI26_0)(a2) +; CHECK-NEXT: vsetvli zero, a1, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v2 +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v2, v24, ft0, v0.t +; CHECK-NEXT: frflags a1 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v2 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a1 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: addi a1, a0, -16 +; CHECK-NEXT: sltu a0, a0, a1 +; CHECK-NEXT: addi a0, a0, -1 +; CHECK-NEXT: and a0, a0, a1 +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v1 +; CHECK-NEXT: vfabs.v v24, v16, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v1, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v1 +; CHECK-NEXT: vfcvt.x.f.v v24, v16, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v16, v24, v16, v0.t +; CHECK-NEXT: ret + %v = call <32 x double> @llvm.vp.nearbyint.v32f64(<32 x double> %va, <32 x i1> %m, i32 %evl) + ret <32 x double> %v +} + +define <32 x double> @vp_nearbyint_v32f64_unmasked(<32 x double> %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_v32f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma +; CHECK-NEXT: li a2, 16 +; CHECK-NEXT: vmset.m v1 +; CHECK-NEXT: mv a1, a0 +; CHECK-NEXT: bltu a0, a2, .LBB27_2 +; CHECK-NEXT: # %bb.1: +; CHECK-NEXT: li a1, 16 +; CHECK-NEXT: .LBB27_2: +; CHECK-NEXT: lui a2, %hi(.LCPI27_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI27_0)(a2) +; CHECK-NEXT: vsetvli zero, a1, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v1 +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmv1r.v v2, v1 +; CHECK-NEXT: vmflt.vf v2, v24, ft0, v0.t +; CHECK-NEXT: frflags a1 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v2 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a1 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: addi a1, a0, -16 +; CHECK-NEXT: sltu a0, a0, a1 +; CHECK-NEXT: addi a0, a0, -1 +; CHECK-NEXT: and a0, a0, a1 +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v1 +; CHECK-NEXT: vfabs.v v24, v16, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v1, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v1 +; CHECK-NEXT: vfcvt.x.f.v v24, v16, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v16, v24, v16, v0.t +; CHECK-NEXT: ret + %head = insertelement <32 x i1> poison, i1 true, i32 0 + %m = shufflevector <32 x i1> %head, <32 x i1> poison, <32 x i32> zeroinitializer + %v = call <32 x double> @llvm.vp.nearbyint.v32f64(<32 x double> %va, <32 x i1> %m, i32 %evl) + ret <32 x double> %v +} diff --git a/llvm/test/CodeGen/RISCV/rvv/nearbyint-vp.ll b/llvm/test/CodeGen/RISCV/rvv/nearbyint-vp.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/nearbyint-vp.ll @@ -0,0 +1,820 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+experimental-zvfh,+v -target-abi=ilp32d \ +; RUN: -verify-machineinstrs < %s | FileCheck %s +; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+experimental-zvfh,+v -target-abi=lp64d \ +; RUN: -verify-machineinstrs < %s | FileCheck %s + +declare @llvm.vp.nearbyint.nxv1f16(, , i32) + +define @vp_nearbyint_nxv1f16( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv1f16: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI0_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI0_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv1f16( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv1f16_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv1f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI1_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI1_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, mf4, ta, ma +; CHECK-NEXT: vfabs.v v9, v8 +; CHECK-NEXT: vmflt.vf v0, v9, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv1f16( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv2f16(, , i32) + +define @vp_nearbyint_nxv2f16( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI2_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI2_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv2f16( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv2f16_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv2f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI3_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI3_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8 +; CHECK-NEXT: vmflt.vf v0, v9, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv2f16( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv4f16(, , i32) + +define @vp_nearbyint_nxv4f16( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI4_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI4_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv4f16( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv4f16_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv4f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI5_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI5_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8 +; CHECK-NEXT: vmflt.vf v0, v9, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv4f16( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv8f16(, , i32) + +define @vp_nearbyint_nxv8f16( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v10, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI6_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI6_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv8f16( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv8f16_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv8f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI7_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI7_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m2, ta, ma +; CHECK-NEXT: vfabs.v v10, v8 +; CHECK-NEXT: vmflt.vf v0, v10, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv8f16( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv16f16(, , i32) + +define @vp_nearbyint_nxv16f16( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v12, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI8_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI8_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, ma +; CHECK-NEXT: vfabs.v v16, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu +; CHECK-NEXT: vmflt.vf v12, v16, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv16f16( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv16f16_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv16f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI9_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI9_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m4, ta, ma +; CHECK-NEXT: vfabs.v v12, v8 +; CHECK-NEXT: vmflt.vf v0, v12, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv16f16( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv32f16(, , i32) + +define @vp_nearbyint_nxv32f16( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv32f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v16, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI10_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI10_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e16, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv32f16( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv32f16_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv32f16_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI11_0) +; CHECK-NEXT: flh ft0, %lo(.LCPI11_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e16, m8, ta, ma +; CHECK-NEXT: vfabs.v v16, v8 +; CHECK-NEXT: vmflt.vf v0, v16, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e16, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv32f16( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv1f32(, , i32) + +define @vp_nearbyint_nxv1f32( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv1f32: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI12_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI12_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv1f32( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv1f32_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv1f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI13_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI13_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, mf2, ta, ma +; CHECK-NEXT: vfabs.v v9, v8 +; CHECK-NEXT: vmflt.vf v0, v9, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv1f32( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv2f32(, , i32) + +define @vp_nearbyint_nxv2f32( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI14_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI14_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv2f32( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv2f32_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv2f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI15_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI15_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8 +; CHECK-NEXT: vmflt.vf v0, v9, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv2f32( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv4f32(, , i32) + +define @vp_nearbyint_nxv4f32( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v10, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI16_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI16_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv4f32( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv4f32_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv4f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI17_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI17_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma +; CHECK-NEXT: vfabs.v v10, v8 +; CHECK-NEXT: vmflt.vf v0, v10, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv4f32( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv8f32(, , i32) + +define @vp_nearbyint_nxv8f32( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v12, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI18_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI18_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma +; CHECK-NEXT: vfabs.v v16, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu +; CHECK-NEXT: vmflt.vf v12, v16, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv8f32( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv8f32_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv8f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI19_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI19_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma +; CHECK-NEXT: vfabs.v v12, v8 +; CHECK-NEXT: vmflt.vf v0, v12, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv8f32( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv16f32(, , i32) + +define @vp_nearbyint_nxv16f32( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v16, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI20_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI20_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e32, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv16f32( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv16f32_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv16f32_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI21_0) +; CHECK-NEXT: flw ft0, %lo(.LCPI21_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma +; CHECK-NEXT: vfabs.v v16, v8 +; CHECK-NEXT: vmflt.vf v0, v16, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e32, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv16f32( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv1f64(, , i32) + +define @vp_nearbyint_nxv1f64( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv1f64: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI22_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI22_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu +; CHECK-NEXT: vmflt.vf v0, v9, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv1f64( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv1f64_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv1f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI23_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI23_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma +; CHECK-NEXT: vfabs.v v9, v8 +; CHECK-NEXT: vmflt.vf v0, v9, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v9, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v9, v9, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v9, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv1f64( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv2f64(, , i32) + +define @vp_nearbyint_nxv2f64( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v10, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI24_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI24_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma +; CHECK-NEXT: vfabs.v v12, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu +; CHECK-NEXT: vmflt.vf v10, v12, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma +; CHECK-NEXT: vmv1r.v v0, v10 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv2f64( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv2f64_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv2f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI25_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI25_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma +; CHECK-NEXT: vfabs.v v10, v8 +; CHECK-NEXT: vmflt.vf v0, v10, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v10, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v10, v10, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v10, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv2f64( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv4f64(, , i32) + +define @vp_nearbyint_nxv4f64( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v12, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI26_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI26_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma +; CHECK-NEXT: vfabs.v v16, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu +; CHECK-NEXT: vmflt.vf v12, v16, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, ma +; CHECK-NEXT: vmv1r.v v0, v12 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv4f64( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv4f64_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv4f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI27_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI27_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma +; CHECK-NEXT: vfabs.v v12, v8 +; CHECK-NEXT: vmflt.vf v0, v12, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v12, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v12, v12, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m4, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v12, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv4f64( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv7f64(, , i32) + +define @vp_nearbyint_nxv7f64( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv7f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v16, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI28_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI28_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv7f64( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv7f64_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv7f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI29_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI29_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v16, v8 +; CHECK-NEXT: vmflt.vf v0, v16, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv7f64( %va, %m, i32 %evl) + ret %v +} + +declare @llvm.vp.nearbyint.nxv8f64(, , i32) + +define @vp_nearbyint_nxv8f64( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v16, v0 +; CHECK-NEXT: lui a1, %hi(.LCPI30_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI30_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v16, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v16 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv8f64( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv8f64_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv8f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: lui a1, %hi(.LCPI31_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI31_0)(a1) +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v16, v8 +; CHECK-NEXT: vmflt.vf v0, v16, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v16, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v16, v16, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v16, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv8f64( %va, %m, i32 %evl) + ret %v +} + +; Test splitting. +declare @llvm.vp.nearbyint.nxv16f64(, , i32) + +define @vp_nearbyint_nxv16f64( %va, %m, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv16f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vmv1r.v v1, v0 +; CHECK-NEXT: csrr a1, vlenb +; CHECK-NEXT: srli a2, a1, 3 +; CHECK-NEXT: vsetvli a3, zero, e8, mf4, ta, ma +; CHECK-NEXT: vslidedown.vx v2, v0, a2 +; CHECK-NEXT: sub a2, a0, a1 +; CHECK-NEXT: sltu a3, a0, a2 +; CHECK-NEXT: addi a3, a3, -1 +; CHECK-NEXT: and a2, a3, a2 +; CHECK-NEXT: lui a3, %hi(.LCPI32_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI32_0)(a3) +; CHECK-NEXT: vsetvli zero, a2, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v2 +; CHECK-NEXT: vfabs.v v24, v16, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v2, v24, ft0, v0.t +; CHECK-NEXT: frflags a2 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v2 +; CHECK-NEXT: vfcvt.x.f.v v24, v16, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a2 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v16, v24, v16, v0.t +; CHECK-NEXT: bltu a0, a1, .LBB32_2 +; CHECK-NEXT: # %bb.1: +; CHECK-NEXT: mv a0, a1 +; CHECK-NEXT: .LBB32_2: +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v1 +; CHECK-NEXT: vfabs.v v24, v8, v0.t +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vmflt.vf v1, v24, ft0, v0.t +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, ma +; CHECK-NEXT: vmv1r.v v0, v1 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %v = call @llvm.vp.nearbyint.nxv16f64( %va, %m, i32 %evl) + ret %v +} + +define @vp_nearbyint_nxv16f64_unmasked( %va, i32 zeroext %evl) { +; CHECK-LABEL: vp_nearbyint_nxv16f64_unmasked: +; CHECK: # %bb.0: +; CHECK-NEXT: csrr a1, vlenb +; CHECK-NEXT: sub a2, a0, a1 +; CHECK-NEXT: lui a3, %hi(.LCPI33_0) +; CHECK-NEXT: fld ft0, %lo(.LCPI33_0)(a3) +; CHECK-NEXT: sltu a3, a0, a2 +; CHECK-NEXT: addi a3, a3, -1 +; CHECK-NEXT: and a2, a3, a2 +; CHECK-NEXT: vsetvli zero, a2, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v16 +; CHECK-NEXT: vmflt.vf v0, v24, ft0 +; CHECK-NEXT: frflags a2 +; CHECK-NEXT: vfcvt.x.f.v v24, v16, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a2 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v16, v24, v16, v0.t +; CHECK-NEXT: bltu a0, a1, .LBB33_2 +; CHECK-NEXT: # %bb.1: +; CHECK-NEXT: mv a0, a1 +; CHECK-NEXT: .LBB33_2: +; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma +; CHECK-NEXT: vfabs.v v24, v8 +; CHECK-NEXT: vmflt.vf v0, v24, ft0 +; CHECK-NEXT: frflags a0 +; CHECK-NEXT: vfcvt.x.f.v v24, v8, v0.t +; CHECK-NEXT: vfcvt.f.x.v v24, v24, v0.t +; CHECK-NEXT: fsflags a0 +; CHECK-NEXT: vsetvli zero, zero, e64, m8, ta, mu +; CHECK-NEXT: vfsgnj.vv v8, v24, v8, v0.t +; CHECK-NEXT: ret + %head = insertelement poison, i1 true, i32 0 + %m = shufflevector %head, poison, zeroinitializer + %v = call @llvm.vp.nearbyint.nxv16f64( %va, %m, i32 %evl) + ret %v +}