diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td b/llvm/include/llvm/IR/IntrinsicsAArch64.td --- a/llvm/include/llvm/IR/IntrinsicsAArch64.td +++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -1998,4 +1998,12 @@ def int_aarch64_sve_sbclb : AdvSIMD_3VectorArg_Intrinsic; def int_aarch64_sve_sbclt : AdvSIMD_3VectorArg_Intrinsic; +// SVE2 bitwise ternary operations. +def int_aarch64_sve_eor3 : AdvSIMD_3VectorArg_Intrinsic; +def int_aarch64_sve_bcax : AdvSIMD_3VectorArg_Intrinsic; +def int_aarch64_sve_bsl : AdvSIMD_3VectorArg_Intrinsic; +def int_aarch64_sve_bsl1n : AdvSIMD_3VectorArg_Intrinsic; +def int_aarch64_sve_bsl2n : AdvSIMD_3VectorArg_Intrinsic; +def int_aarch64_sve_nbsl : AdvSIMD_3VectorArg_Intrinsic; + } diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td --- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -1738,12 +1738,12 @@ defm FMLSLT_ZZZ_SHH : sve2_fp_mla_long<0b11, "fmlslt", int_aarch64_sve_fmlslt>; // SVE2 bitwise ternary operations - defm EOR3_ZZZZ_D : sve2_int_bitwise_ternary_op<0b000, "eor3">; - defm BCAX_ZZZZ_D : sve2_int_bitwise_ternary_op<0b010, "bcax">; - def BSL_ZZZZ_D : sve2_int_bitwise_ternary_op_d<0b001, "bsl">; - def BSL1N_ZZZZ_D : sve2_int_bitwise_ternary_op_d<0b011, "bsl1n">; - def BSL2N_ZZZZ_D : sve2_int_bitwise_ternary_op_d<0b101, "bsl2n">; - def NBSL_ZZZZ_D : sve2_int_bitwise_ternary_op_d<0b111, "nbsl">; + defm EOR3_ZZZZ : sve2_int_bitwise_ternary_op<0b000, "eor3", int_aarch64_sve_eor3>; + defm BCAX_ZZZZ : sve2_int_bitwise_ternary_op<0b010, "bcax", int_aarch64_sve_bcax>; + defm BSL_ZZZZ : sve2_int_bitwise_ternary_op_d<0b001, "bsl", int_aarch64_sve_bsl>; + defm BSL1N_ZZZZ : sve2_int_bitwise_ternary_op_d<0b011, "bsl1n", int_aarch64_sve_bsl1n>; + defm BSL2N_ZZZZ : sve2_int_bitwise_ternary_op_d<0b101, "bsl2n", int_aarch64_sve_bsl2n>; + defm NBSL_ZZZZ : sve2_int_bitwise_ternary_op_d<0b111, "nbsl", int_aarch64_sve_nbsl>; // SVE2 bitwise xor and rotate right by immediate defm XAR_ZZZI : sve2_int_rotate_right_imm<"xar">; diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td b/llvm/lib/Target/AArch64/SVEInstrFormats.td --- a/llvm/lib/Target/AArch64/SVEInstrFormats.td +++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td @@ -3744,7 +3744,14 @@ let ElementSize = ElementSizeNone; } -multiclass sve2_int_bitwise_ternary_op opc, string asm> { + +multiclass sve2_int_bitwise_ternary_op_d opc, string asm, SDPatternOperator op> { + def NAME : sve2_int_bitwise_ternary_op_d; + + def : SVE_3_Op_Pat(NAME)>; +} + +multiclass sve2_int_bitwise_ternary_op opc, string asm, SDPatternOperator op> { def NAME : sve2_int_bitwise_ternary_op_d; def : InstAlias(NAME) ZPR16:$Zdn, ZPR16:$Zm, ZPR16:$Zk), 1>; def : InstAlias(NAME) ZPR32:$Zdn, ZPR32:$Zm, ZPR32:$Zk), 1>; + + def : SVE_3_Op_Pat(NAME)>; + def : SVE_3_Op_Pat(NAME)>; + def : SVE_3_Op_Pat(NAME)>; + def : SVE_3_Op_Pat(NAME)>; } class sve2_int_rotate_right_imm tsz8_64, string asm, diff --git a/llvm/test/CodeGen/AArch64/sve2-bitwise-ternary.ll b/llvm/test/CodeGen/AArch64/sve2-bitwise-ternary.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve2-bitwise-ternary.ll @@ -0,0 +1,152 @@ +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s + +; +; EOR3 (vector, bitwise, unpredicated) +; +define @eor3_i8( %a, + %b, + %c) { +; CHECK-LABEL: eor3_i8 +; CHECK: eor3 z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.eor3.nxv16i8( %a, %b, %c) + ret %res +} + +define @eor3_i16( %a, + %b, + %c) { +; CHECK-LABEL: eor3_i16 +; CHECK: eor3 z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.eor3.nxv8i16( %a, %b, %c) + ret %res +} + +define @eor3_i32( %a, + %b, + %c) { +; CHECK-LABEL: eor3_i32 +; CHECK: eor3 z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.eor3.nxv4i32( %a, %b, %c) + ret %res +} + +define @eor3_i64( %a, + %b, + %c) { +; CHECK-LABEL: eor3_i64 +; CHECK: eor3 z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.eor3.nxv2i64( %a, %b, %c) + ret %res +} + +; +; BCAX (vector, bitwise, unpredicated) +; +define @bcax_i8( %a, + %b, + %c) { +; CHECK-LABEL: bcax_i8 +; CHECK: bcax z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.bcax.nxv16i8( %a, %b, %c) + ret %res +} + +define @bcax_i16( %a, + %b, + %c) { +; CHECK-LABEL: bcax_i16 +; CHECK: bcax z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.bcax.nxv8i16( %a, %b, %c) + ret %res +} + +define @bcax_i32( %a, + %b, + %c) { +; CHECK-LABEL: bcax_i32 +; CHECK: bcax z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.bcax.nxv4i32( %a, %b, %c) + ret %res +} + +define @bcax_i64( %a, + %b, + %c) { +; CHECK-LABEL: bcax_i64 +; CHECK: bcax z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.bcax.nxv2i64( %a, %b, %c) + ret %res +} + +; +; BSL (vector, bitwise, unpredicated) +; +define @bsl_i64( %a, + %b, + %c) { +; CHECK-LABEL: bsl_i64 +; CHECK: bsl z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.bsl.nxv2i64( %a, %b, %c) + ret %res +} + +; +; BSL1N (vector, bitwise, unpredicated) +; +define @bsl1n_i64( %a, + %b, + %c) { +; CHECK-LABEL: bsl1n_i64 +; CHECK: bsl1n z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.bsl1n.nxv2i64( %a, %b, %c) + ret %res +} + +; +; BSL2N (vector, bitwise, unpredicated) +; +define @bsl2n_i64( %a, + %b, + %c) { +; CHECK-LABEL: bsl2n_i64 +; CHECK: bsl2n z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.bsl2n.nxv2i64( %a, %b, %c) + ret %res +} + +; +; NBSL (vector, bitwise, unpredicated) +; +define @nbsl_i64( %a, + %b, + %c) { +; CHECK-LABEL: nbsl_i64 +; CHECK: nbsl z0.d, z0.d, z1.d, z2.d +; CHECK-NEXT: ret + %res = call @llvm.aarch64.sve.nbsl.nxv2i64( %a, %b, %c) + ret %res +} + +declare @llvm.aarch64.sve.eor3.nxv16i8(,,) +declare @llvm.aarch64.sve.eor3.nxv8i16(,,) +declare @llvm.aarch64.sve.eor3.nxv4i32(,,) +declare @llvm.aarch64.sve.eor3.nxv2i64(,,) +declare @llvm.aarch64.sve.bcax.nxv16i8(,,) +declare @llvm.aarch64.sve.bcax.nxv8i16(,,) +declare @llvm.aarch64.sve.bcax.nxv4i32(,,) +declare @llvm.aarch64.sve.bcax.nxv2i64(,,) +declare @llvm.aarch64.sve.bsl.nxv2i64(,,) +declare @llvm.aarch64.sve.bsl1n.nxv2i64(,,) +declare @llvm.aarch64.sve.bsl2n.nxv2i64(,,) +declare @llvm.aarch64.sve.nbsl.nxv2i64(,,) \ No newline at end of file