Index: llvm/include/llvm/IR/IntrinsicsAArch64.td =================================================================== --- llvm/include/llvm/IR/IntrinsicsAArch64.td +++ llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -790,6 +790,12 @@ llvm_i32_ty], [IntrNoMem]>; + class AdvSIMD_Pred1VectorArg_Intrinsic + : Intrinsic<[llvm_anyvector_ty], + [LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, + LLVMMatchType<0>], + [IntrNoMem]>; + class AdvSIMD_Pred2VectorArg_Intrinsic : Intrinsic<[llvm_anyvector_ty], [LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, @@ -1351,6 +1357,8 @@ // Predicate operations // +def int_aarch64_sve_pfirst : AdvSIMD_Pred1VectorArg_Intrinsic; +def int_aarch64_sve_pnext : AdvSIMD_Pred1VectorArg_Intrinsic; def int_aarch64_sve_punpkhi : AdvSIMD_SVE_PUNPKHI_Intrinsic; def int_aarch64_sve_punpklo : AdvSIMD_SVE_PUNPKHI_Intrinsic; Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td =================================================================== --- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -277,8 +277,8 @@ def PTEST_PP : sve_int_ptest<0b010000, "ptest">; def PFALSE : sve_int_pfalse<0b000000, "pfalse">; - defm PFIRST : sve_int_pfirst<0b00000, "pfirst">; - defm PNEXT : sve_int_pnext<0b00110, "pnext">; + defm PFIRST : sve_int_pfirst<0b00000, "pfirst", int_aarch64_sve_pfirst>; + defm PNEXT : sve_int_pnext<0b00110, "pnext", int_aarch64_sve_pnext>; defm AND_PPzPP : sve_int_pred_log<0b0000, "and", int_aarch64_sve_and>; defm BIC_PPzPP : sve_int_pred_log<0b0001, "bic", int_aarch64_sve_bic>; Index: llvm/lib/Target/AArch64/SVEInstrFormats.td =================================================================== --- llvm/lib/Target/AArch64/SVEInstrFormats.td +++ llvm/lib/Target/AArch64/SVEInstrFormats.td @@ -398,15 +398,22 @@ let Defs = [NZCV]; } -multiclass sve_int_pfirst opc, string asm> { - def : sve_int_pfirst_next<0b01, opc, asm, PPR8>; +multiclass sve_int_pfirst opc, string asm, SDPatternOperator op> { + def _B : sve_int_pfirst_next<0b01, opc, asm, PPR8>; + + def : SVE_2_Op_Pat(NAME # _B)>; } -multiclass sve_int_pnext opc, string asm> { +multiclass sve_int_pnext opc, string asm, SDPatternOperator op> { def _B : sve_int_pfirst_next<0b00, opc, asm, PPR8>; def _H : sve_int_pfirst_next<0b01, opc, asm, PPR16>; def _S : sve_int_pfirst_next<0b10, opc, asm, PPR32>; def _D : sve_int_pfirst_next<0b11, opc, asm, PPR64>; + + def : SVE_2_Op_Pat(NAME # _B)>; + def : SVE_2_Op_Pat(NAME # _H)>; + def : SVE_2_Op_Pat(NAME # _S)>; + def : SVE_2_Op_Pat(NAME # _D)>; } //===----------------------------------------------------------------------===// Index: llvm/test/CodeGen/AArch64/sve-intrinsics-pred-operations.ll =================================================================== --- llvm/test/CodeGen/AArch64/sve-intrinsics-pred-operations.ll +++ llvm/test/CodeGen/AArch64/sve-intrinsics-pred-operations.ll @@ -1,6 +1,64 @@ ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s ; +; PFIRST +; + +define @pfirst_b8( %pg, %a) { +; CHECK-LABEL: pfirst_b8: +; CHECK: pfirst p1.b, p0, p1.b +; CHECK-NEXT: mov p0.b, p1.b +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.pfirst.nxv16i1( %pg, + %a) + ret %out +} + +; +; PNEXT +; + +define @pnext_b8( %pg, %a) { +; CHECK-LABEL: pnext_b8: +; CHECK: pnext p1.b, p0, p1.b +; CHECK-NEXT: mov p0.b, p1.b +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.pnext.nxv16i1( %pg, + %a) + ret %out +} + +define @pnext_b16( %pg, %a) { +; CHECK-LABEL: pnext_b16: +; CHECK: pnext p1.h, p0, p1.h +; CHECK-NEXT: mov p0.b, p1.b +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.pnext.nxv8i1( %pg, + %a) + ret %out +} + +define @pnext_b32( %pg, %a) { +; CHECK-LABEL: pnext_b32: +; CHECK: pnext p1.s, p0, p1.s +; CHECK-NEXT: mov p0.b, p1.b +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.pnext.nxv4i1( %pg, + %a) + ret %out +} + +define @pnext_b64( %pg, %a) { +; CHECK-LABEL: pnext_b64: +; CHECK: pnext p1.d, p0, p1.d +; CHECK-NEXT: mov p0.b, p1.b +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.pnext.nxv2i1( %pg, + %a) + ret %out +} + +; ; PUNPKHI ; @@ -56,6 +114,13 @@ ret %res } +declare @llvm.aarch64.sve.pfirst.nxv16i1(, ) + +declare @llvm.aarch64.sve.pnext.nxv16i1(, ) +declare @llvm.aarch64.sve.pnext.nxv8i1(, ) +declare @llvm.aarch64.sve.pnext.nxv4i1(, ) +declare @llvm.aarch64.sve.pnext.nxv2i1(, ) + declare @llvm.aarch64.sve.punpkhi.nxv8i1() declare @llvm.aarch64.sve.punpkhi.nxv4i1() declare @llvm.aarch64.sve.punpkhi.nxv2i1()