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 @@ -374,6 +374,39 @@ // We must custom-lower SPLAT_VECTOR vXi64 on RV32 if (!Subtarget.is64Bit()) setOperationAction(ISD::SPLAT_VECTOR, MVT::i64, Custom); + + ISD::CondCode VFPCCToExpand[] = {ISD::SETO, ISD::SETONE, ISD::SETUEQ, + ISD::SETUGT, ISD::SETUGE, ISD::SETULT, + ISD::SETULE, ISD::SETUO}; + + if (Subtarget.hasStdExtZfh()) { + for (auto VT : {RISCVVMVTs::vfloat16mf4_t, RISCVVMVTs::vfloat16mf2_t, + RISCVVMVTs::vfloat16m1_t, RISCVVMVTs::vfloat16m2_t, + RISCVVMVTs::vfloat16m4_t, RISCVVMVTs::vfloat16m8_t}) { + setOperationAction(ISD::SPLAT_VECTOR, VT, Legal); + for (auto CC : VFPCCToExpand) + setCondCodeAction(CC, VT, Expand); + } + } + + if (Subtarget.hasStdExtF()) { + for (auto VT : {RISCVVMVTs::vfloat32mf2_t, RISCVVMVTs::vfloat32m1_t, + RISCVVMVTs::vfloat32m2_t, RISCVVMVTs::vfloat32m4_t, + RISCVVMVTs::vfloat32m8_t}) { + setOperationAction(ISD::SPLAT_VECTOR, VT, Legal); + for (auto CC : VFPCCToExpand) + setCondCodeAction(CC, VT, Expand); + } + } + + if (Subtarget.hasStdExtD()) { + for (auto VT : {RISCVVMVTs::vfloat64m1_t, RISCVVMVTs::vfloat64m2_t, + RISCVVMVTs::vfloat64m4_t, RISCVVMVTs::vfloat64m8_t}) { + setOperationAction(ISD::SPLAT_VECTOR, VT, Legal); + for (auto CC : VFPCCToExpand) + setCondCodeAction(CC, VT, Expand); + } + } } // Function alignments. diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td @@ -186,6 +186,24 @@ defm "" : VPatBinarySDNode_VV_VX; defm "" : VPatBinarySDNode_VV_VX; +// 12.16. Vector Integer Merge Instructions +foreach vti = AllIntegerVectors in { + def : Pat<(vti.Vector (vselect (vti.Mask VMV0:$vm), vti.RegClass:$rs1, + vti.RegClass:$rs2)), + (!cast("PseudoVMERGE_VVM_"#vti.LMul.MX) + vti.RegClass:$rs2, vti.RegClass:$rs1, VMV0:$vm, VLMax, vti.SEW)>; + + def : Pat<(vti.Vector (vselect (vti.Mask VMV0:$vm), (SplatPat XLenVT:$rs1), + vti.RegClass:$rs2)), + (!cast("PseudoVMERGE_VXM_"#vti.LMul.MX) + vti.RegClass:$rs2, GPR:$rs1, VMV0:$vm, VLMax, vti.SEW)>; + + def : Pat<(vti.Vector (vselect (vti.Mask VMV0:$vm), (SplatPat_simm5 simm5:$rs1), + vti.RegClass:$rs2)), + (!cast("PseudoVMERGE_VIM_"#vti.LMul.MX) + vti.RegClass:$rs2, simm5:$rs1, VMV0:$vm, VLMax, vti.SEW)>; +} + // 16.1. Vector Mask-Register Logical Instructions foreach mti = AllMasks in { def : Pat<(mti.Mask (and VR:$rs1, VR:$rs2)), @@ -218,6 +236,27 @@ } // Predicates = [HasStdExtV] +let Predicates = [HasStdExtV, HasStdExtF] in { +// Floating-point vselects: +// 12.16. Vector Integer Merge Instructions +// 14.13. Vector Floating-Point Merge Instruction +foreach fvti = AllFloatVectors in { + def : Pat<(fvti.Vector (vselect (fvti.Mask VMV0:$vm), fvti.RegClass:$rs1, + fvti.RegClass:$rs2)), + (!cast("PseudoVMERGE_VVM_"#fvti.LMul.MX) + fvti.RegClass:$rs2, fvti.RegClass:$rs1, VMV0:$vm, + VLMax, fvti.SEW)>; + + def : Pat<(fvti.Vector (vselect (fvti.Mask VMV0:$vm), + (splat_vector fvti.ScalarRegClass:$rs1), + fvti.RegClass:$rs2)), + (!cast("PseudoVFMERGE_VFM_"#fvti.LMul.MX) + fvti.RegClass:$rs2, + ToFPR32.ret, + VMV0:$vm, VLMax, fvti.SEW)>; +} +} // Predicates = [HasStdExtV, HasStdExtF] + //===----------------------------------------------------------------------===// // Vector Splats //===----------------------------------------------------------------------===// diff --git a/llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv32.ll b/llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv32.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv32.ll @@ -0,0 +1,343 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=ilp32d \ +; RUN: -verify-machineinstrs < %s | FileCheck %s + +define @vfmerge_vv_nxv1f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv1f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv1f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv1f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv2f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv2f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv4f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv4f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv8f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv8f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv16f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv16f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv32f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv32f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vle16.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv32f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv32f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m8,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv1f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv1f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv1f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv1f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv2f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv2f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv4f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv4f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv8f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv8f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv16f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vle32.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv16f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m8,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv1f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv1f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv1f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv1f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv2f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv2f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv4f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv4f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv8f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,ta,mu +; CHECK-NEXT: vle64.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv8f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m8,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + diff --git a/llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv64.ll b/llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv64.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv64.ll @@ -0,0 +1,343 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv64 -mattr=+d,+experimental-zfh,+experimental-v -target-abi=lp64d \ +; RUN: -verify-machineinstrs < %s | FileCheck %s + +define @vfmerge_vv_nxv1f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv1f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv1f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv1f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv2f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv2f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv2f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv4f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv4f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv4f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv8f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv8f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv8f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv16f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv16f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv16f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv32f16( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv32f16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vle16.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv32f16( %va, half %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv32f16: +; CHECK: # %bb.0: +; CHECK-NEXT: # kill: def $f10_h killed $f10_h def $f10_f +; CHECK-NEXT: vsetvli a0, zero, e16,m8,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, half %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv1f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv1f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv1f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv1f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv2f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv2f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv2f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv4f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv4f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv4f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv8f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv8f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv8f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv16f32( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vle32.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv16f32( %va, float %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv16f32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m8,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, float %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv1f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv1f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv1f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv1f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv2f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv2f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv2f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv4f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv4f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv4f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vfmerge_vv_nxv8f64( %va, %vb, %cond) { +; CHECK-LABEL: vfmerge_vv_nxv8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,ta,mu +; CHECK-NEXT: vle64.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vfmerge_fv_nxv8f64( %va, double %b, %cond) { +; CHECK-LABEL: vfmerge_fv_nxv8f64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m8,ta,mu +; CHECK-NEXT: vfmerge.vfm v16, v16, fa0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, double %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + diff --git a/llvm/test/CodeGen/RISCV/rvv/vselect-int-rv32.ll b/llvm/test/CodeGen/RISCV/rvv/vselect-int-rv32.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/vselect-int-rv32.ll @@ -0,0 +1,783 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv32 -mattr=+experimental-v -verify-machineinstrs < %s | FileCheck %s + +define @vmerge_vv_nxv1i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf8,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m1,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv16i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv16i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv16i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv32i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv32i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv32i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv64i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m8,ta,mu +; CHECK-NEXT: vle8.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv64i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv64i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv1i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv16i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv16i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv16i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv32i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vle16.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv32i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv32i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv1i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i32( %va, i32 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i32( %va, i32 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i32( %va, i32 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i32( %va, i32 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv16i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vle32.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv16i32( %va, i32 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv16i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv1i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a2, zero, e64,m1,ta,mu +; CHECK-NEXT: vmv.v.x v25, a1 +; CHECK-NEXT: addi a1, zero, 32 +; CHECK-NEXT: vsll.vx v25, v25, a1 +; CHECK-NEXT: vmv.v.x v26, a0 +; CHECK-NEXT: vsll.vx v26, v26, a1 +; CHECK-NEXT: vsrl.vx v26, v26, a1 +; CHECK-NEXT: vor.vv v25, v26, v25 +; CHECK-NEXT: vmerge.vvm v16, v16, v25, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a2, zero, e64,m2,ta,mu +; CHECK-NEXT: vmv.v.x v26, a1 +; CHECK-NEXT: addi a1, zero, 32 +; CHECK-NEXT: vsll.vx v26, v26, a1 +; CHECK-NEXT: vmv.v.x v28, a0 +; CHECK-NEXT: vsll.vx v28, v28, a1 +; CHECK-NEXT: vsrl.vx v28, v28, a1 +; CHECK-NEXT: vor.vv v26, v28, v26 +; CHECK-NEXT: vmerge.vvm v16, v16, v26, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a2, zero, e64,m4,ta,mu +; CHECK-NEXT: vmv.v.x v28, a1 +; CHECK-NEXT: addi a1, zero, 32 +; CHECK-NEXT: vsll.vx v28, v28, a1 +; CHECK-NEXT: vmv.v.x v8, a0 +; CHECK-NEXT: vsll.vx v8, v8, a1 +; CHECK-NEXT: vsrl.vx v8, v8, a1 +; CHECK-NEXT: vor.vv v28, v8, v28 +; CHECK-NEXT: vmerge.vvm v16, v16, v28, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,ta,mu +; CHECK-NEXT: vle64.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a2, zero, e64,m8,ta,mu +; CHECK-NEXT: vmv.v.x v8, a1 +; CHECK-NEXT: addi a1, zero, 32 +; CHECK-NEXT: vsll.vx v8, v8, a1 +; CHECK-NEXT: vmv.v.x v24, a0 +; CHECK-NEXT: vsll.vx v24, v24, a1 +; CHECK-NEXT: vsrl.vx v24, v24, a1 +; CHECK-NEXT: vor.vv v8, v24, v8 +; CHECK-NEXT: vmerge.vvm v16, v16, v8, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + diff --git a/llvm/test/CodeGen/RISCV/rvv/vselect-int-rv64.ll b/llvm/test/CodeGen/RISCV/rvv/vselect-int-rv64.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/RISCV/rvv/vselect-int-rv64.ll @@ -0,0 +1,755 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -verify-machineinstrs < %s | FileCheck %s + +define @vmerge_vv_nxv1i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf8,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,mf2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,mf2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m1,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv16i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv16i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv16i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv16i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv32i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv32i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv32i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv32i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv64i8( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m8,ta,mu +; CHECK-NEXT: vle8.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv64i8( %va, i8 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e8,m8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv64i8( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv64i8: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e8,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i8 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv1i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,mf2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv16i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv16i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv16i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv16i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv32i16( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vle16.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv32i16( %va, i16 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e16,m8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv32i16( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv32i16: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e16,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i16 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv1i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i32( %va, i32 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,mf2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i32( %va, i32 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i32( %va, i32 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i32( %va, i32 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv16i32( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vle32.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv16i32( %va, i32 signext %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e32,m8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv16i32( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv16i32: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e32,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i32 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv1i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v17, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv1i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m1,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv1i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv1i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m1,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv2i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v18, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv2i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m2,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv2i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv2i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m2,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv4i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vmerge.vvm v16, v20, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv4i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m4,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv4i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv4i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m4,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_vv_nxv8i64( %va, %vb, %cond) { +; CHECK-LABEL: vmerge_vv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,ta,mu +; CHECK-NEXT: vle64.v v8, (a0) +; CHECK-NEXT: vmerge.vvm v16, v8, v16, v0 +; CHECK-NEXT: ret + %vc = select %cond, %va, %vb + ret %vc +} + +define @vmerge_xv_nxv8i64( %va, i64 %b, %cond) { +; CHECK-LABEL: vmerge_xv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a1, zero, e64,m8,ta,mu +; CHECK-NEXT: vmerge.vxm v16, v16, a0, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 %b, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} + +define @vmerge_iv_nxv8i64( %va, %cond) { +; CHECK-LABEL: vmerge_iv_nxv8i64: +; CHECK: # %bb.0: +; CHECK-NEXT: vsetvli a0, zero, e64,m8,ta,mu +; CHECK-NEXT: vmerge.vim v16, v16, 3, v0 +; CHECK-NEXT: ret + %head = insertelement undef, i64 3, i32 0 + %splat = shufflevector %head, undef, zeroinitializer + %vc = select %cond, %splat, %va + ret %vc +} +