Index: llvm/include/llvm/IR/IntrinsicsAArch64.td =================================================================== --- llvm/include/llvm/IR/IntrinsicsAArch64.td +++ llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -1103,6 +1103,23 @@ llvm_i64_ty], [IntrNoMem, ImmArg<3>]>; + class AdvSIMD_SVE_CDOT_Intrinsic + : Intrinsic<[llvm_anyvector_ty], + [LLVMMatchType<0>, + LLVMSubdivide4VectorType<0>, + LLVMSubdivide4VectorType<0>, + llvm_i32_ty], + [IntrNoMem]>; + + class AdvSIMD_SVE_CDOT_LANE_Intrinsic + : Intrinsic<[llvm_anyvector_ty], + [LLVMMatchType<0>, + LLVMSubdivide4VectorType<0>, + LLVMSubdivide4VectorType<0>, + llvm_i32_ty, + llvm_i32_ty], + [IntrNoMem, ImmArg<3>]>; + // NOTE: There is no relationship between these intrinsics beyond an attempt // to reuse currently identical class definitions. class AdvSIMD_SVE_LOGB_Intrinsic : AdvSIMD_SVE_CNT_Intrinsic; @@ -1697,6 +1714,13 @@ def int_aarch64_sve_ursqrte : AdvSIMD_Merged1VectorArg_Intrinsic; // +// SVE2 - Widening complex integer dot product +// + +def int_aarch64_sve_cdot : AdvSIMD_SVE_CDOT_Intrinsic; +def int_aarch64_sve_cdot_lane : AdvSIMD_SVE_CDOT_LANE_Intrinsic; + +// // SVE2 - Non-widening pairwise arithmetic // Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td =================================================================== --- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -1442,10 +1442,10 @@ def : Pat<(nxv2i64 (int_aarch64_sve_umulh (nxv2i1 (AArch64ptrue 31)), nxv2i64:$Op1, nxv2i64:$Op2)), (UMULH_ZZZ_D $Op1, $Op2)>; // SVE2 complex integer dot product (indexed) - defm CDOT_ZZZI : sve2_cintx_dot_by_indexed_elem<"cdot">; + defm CDOT_ZZZI : sve2_cintx_dot_by_indexed_elem<"cdot", int_aarch64_sve_cdot_lane>; // SVE2 complex integer dot product - defm CDOT_ZZZ : sve2_cintx_dot<"cdot">; + defm CDOT_ZZZ : sve2_cintx_dot<"cdot", int_aarch64_sve_cdot>; // SVE2 complex integer multiply-add (indexed) defm CMLA_ZZZI : sve2_cmla_by_indexed_elem<0b0, "cmla">; Index: llvm/lib/Target/AArch64/SVEInstrFormats.td =================================================================== --- llvm/lib/Target/AArch64/SVEInstrFormats.td +++ llvm/lib/Target/AArch64/SVEInstrFormats.td @@ -2538,9 +2538,16 @@ let ElementSize = ElementSizeNone; } -multiclass sve2_cintx_dot { +multiclass sve2_cintx_dot { def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>; def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>; + + def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3), + (i32 complexrotateop:$imm))), + (!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>; + def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3), + (i32 complexrotateop:$imm))), + (!cast(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>; } //===----------------------------------------------------------------------===// @@ -2580,19 +2587,26 @@ let ElementSize = ElementSizeNone; } -multiclass sve2_cintx_dot_by_indexed_elem { - def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> { +multiclass sve2_cintx_dot_by_indexed_elem { + def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> { bits<2> iop; bits<3> Zm; let Inst{20-19} = iop; let Inst{18-16} = Zm; } - def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> { + def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> { bit iop; bits<4> Zm; let Inst{20} = iop; let Inst{19-16} = Zm; } + + def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3), + (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))), + (!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>; + def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3), + (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))), + (!cast(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>; } //===----------------------------------------------------------------------===// Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll @@ -0,0 +1,61 @@ +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s + + +; +; CDOT +; + +define @cdot_s( %a, %b, %c) { +; CHECK-LABEL: cdot_s: +; CHECK: cdot z0.s, z1.b, z2.b, #0 +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.cdot.nxv4i32( %a, + %b, + %c, + i32 0) + ret %out +} + +define @cdot_d( %a, %b, %c) { +; CHECK-LABEL: cdot_d: +; CHECK: cdot z0.d, z1.h, z2.h, #90 +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.cdot.nxv2i64( %a, + %b, + %c, + i32 90) + ret %out +} + +; +; CDOT(indexed) +; + +define @cdot_s_idx( %a, %b, %c) { +; CHECK-LABEL: cdot_s_idx: +; CHECK: cdot z0.s, z1.b, z2.b[0], #180 +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.cdot.lane.nxv4i32( %a, + %b, + %c, + i32 0, i32 180) + ret %out +} + + +define @cdot_d_idx( %a, %b, %c) { +; CHECK-LABEL: cdot_d_idx: +; CHECK: cdot z0.d, z1.h, z2.h[1], #270 +; CHECK-NEXT: ret + %out = call @llvm.aarch64.sve.cdot.lane.nxv2i64( %a, + %b, + %c, + i32 1, i32 270) + ret %out +} + + +declare @llvm.aarch64.sve.cdot.nxv4i32(, , , i32) +declare @llvm.aarch64.sve.cdot.nxv2i64(, , , i32) +declare @llvm.aarch64.sve.cdot.lane.nxv4i32(, , , i32, i32) +declare @llvm.aarch64.sve.cdot.lane.nxv2i64(, , , i32, i32)