mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[AArch64] Codegen for v8.2A dot product intrinsics
This adds IR intrinsics for the AArch64 dot-product instructions introduced in v8.2-A. Differential revisioon: https://reviews.llvm.org/D46107 llvm-svn: 331036
This commit is contained in:
parent
c0666ae6d5
commit
9fd29cce52
@ -149,6 +149,11 @@ let TargetPrefix = "aarch64" in { // All intrinsics start with "llvm.aarch64.".
|
||||
|
||||
class AdvSIMD_1Arg_Intrinsic
|
||||
: Intrinsic<[llvm_any_ty], [LLVMMatchType<0>], [IntrNoMem]>;
|
||||
|
||||
class AdvSIMD_Dot_Intrinsic
|
||||
: Intrinsic<[llvm_anyvector_ty],
|
||||
[LLVMMatchType<0>, llvm_anyvector_ty, LLVMMatchType<1>],
|
||||
[IntrNoMem]>;
|
||||
}
|
||||
|
||||
// Arithmetic ops
|
||||
@ -415,6 +420,10 @@ let TargetPrefix = "aarch64", IntrProperties = [IntrNoMem] in {
|
||||
// Scalar FP Inexact Narrowing
|
||||
def int_aarch64_sisd_fcvtxn : Intrinsic<[llvm_float_ty], [llvm_double_ty],
|
||||
[IntrNoMem]>;
|
||||
|
||||
// v8.2-A Dot Product
|
||||
def int_aarch64_neon_udot : AdvSIMD_Dot_Intrinsic;
|
||||
def int_aarch64_neon_sdot : AdvSIMD_Dot_Intrinsic;
|
||||
}
|
||||
|
||||
let TargetPrefix = "aarch64" in { // All intrinsics start with "llvm.aarch64.".
|
||||
|
@ -4595,11 +4595,24 @@ class BaseSIMDThreeSameVectorTied<bit Q, bit U, bits<3> size, bits<5> opcode,
|
||||
}
|
||||
|
||||
class BaseSIMDThreeSameVectorDot<bit Q, bit U, string asm, string kind1,
|
||||
string kind2> :
|
||||
BaseSIMDThreeSameVector<Q, U, 0b100, 0b10010, V128, asm, kind1, [] > {
|
||||
string kind2, RegisterOperand RegType,
|
||||
ValueType AccumType, ValueType InputType,
|
||||
SDPatternOperator OpNode> :
|
||||
BaseSIMDThreeSameVectorTied<Q, U, 0b100, 0b10010, RegType, asm, kind1,
|
||||
[(set (AccumType RegType:$dst),
|
||||
(OpNode (AccumType RegType:$Rd),
|
||||
(InputType RegType:$Rn),
|
||||
(InputType RegType:$Rm)))]> {
|
||||
let AsmString = !strconcat(asm, "{\t$Rd" # kind1 # ", $Rn" # kind2 # ", $Rm" # kind2 # "}");
|
||||
}
|
||||
|
||||
multiclass SIMDThreeSameVectorDot<bit U, string asm, SDPatternOperator OpNode> {
|
||||
def v8i8 : BaseSIMDThreeSameVectorDot<0, U, asm, ".2s", ".8b", V64,
|
||||
v2i32, v8i8, OpNode>;
|
||||
def v16i8 : BaseSIMDThreeSameVectorDot<1, U, asm, ".4s", ".16b", V128,
|
||||
v4i32, v16i8, OpNode>;
|
||||
}
|
||||
|
||||
// All operand sizes distinguished in the encoding.
|
||||
multiclass SIMDThreeSameVector<bit U, bits<5> opc, string asm,
|
||||
SDPatternOperator OpNode> {
|
||||
@ -7029,14 +7042,31 @@ class BaseSIMDIndexedTied<bit Q, bit U, bit Scalar, bits<2> size, bits<4> opc,
|
||||
|
||||
// ARMv8.2 Index Dot product instructions
|
||||
class BaseSIMDThreeSameVectorDotIndex<bit Q, bit U, string asm, string dst_kind,
|
||||
string lhs_kind, string rhs_kind> :
|
||||
BaseSIMDIndexedTied<Q, U, 0b0, 0b10, 0b1110, V128, V128, V128, VectorIndexS,
|
||||
asm, "", dst_kind, lhs_kind, rhs_kind, []> {
|
||||
string lhs_kind, string rhs_kind,
|
||||
RegisterOperand RegType,
|
||||
ValueType AccumType, ValueType InputType,
|
||||
SDPatternOperator OpNode> :
|
||||
BaseSIMDIndexedTied<Q, U, 0b0, 0b10, 0b1110, RegType, RegType, V128,
|
||||
VectorIndexS, asm, "", dst_kind, lhs_kind, rhs_kind,
|
||||
[(set (AccumType RegType:$dst),
|
||||
(AccumType (OpNode (AccumType RegType:$Rd),
|
||||
(InputType RegType:$Rn),
|
||||
(InputType (bitconvert (AccumType
|
||||
(AArch64duplane32 (v4i32 V128:$Rm),
|
||||
VectorIndexS:$idx)))))))]> {
|
||||
bits<2> idx;
|
||||
let Inst{21} = idx{0}; // L
|
||||
let Inst{11} = idx{1}; // H
|
||||
}
|
||||
|
||||
multiclass SIMDThreeSameVectorDotIndex<bit U, string asm,
|
||||
SDPatternOperator OpNode> {
|
||||
def v8i8 : BaseSIMDThreeSameVectorDotIndex<0, U, asm, ".2s", ".8b", ".4b", V64,
|
||||
v2i32, v8i8, OpNode>;
|
||||
def v16i8 : BaseSIMDThreeSameVectorDotIndex<1, U, asm, ".4s", ".16b", ".4b", V128,
|
||||
v4i32, v16i8, OpNode>;
|
||||
}
|
||||
|
||||
multiclass SIMDFPIndexed<bit U, bits<4> opc, string asm,
|
||||
SDPatternOperator OpNode> {
|
||||
let Predicates = [HasNEON, HasFullFP16] in {
|
||||
|
@ -453,14 +453,10 @@ def ISB : CRmSystemI<barrier_op, 0b110, "isb",
|
||||
|
||||
// ARMv8.2 Dot Product
|
||||
let Predicates = [HasDotProd] in {
|
||||
def UDOT2S : BaseSIMDThreeSameVectorDot<0, 1, "udot", ".2s", ".8b">;
|
||||
def SDOT2S : BaseSIMDThreeSameVectorDot<0, 0, "sdot", ".2s", ".8b">;
|
||||
def UDOT4S : BaseSIMDThreeSameVectorDot<1, 1, "udot", ".4s", ".16b">;
|
||||
def SDOT4S : BaseSIMDThreeSameVectorDot<1, 0, "sdot", ".4s", ".16b">;
|
||||
def UDOTIDX2S : BaseSIMDThreeSameVectorDotIndex<0, 1, "udot", ".2s", ".8b", ".4b">;
|
||||
def SDOTIDX2S : BaseSIMDThreeSameVectorDotIndex<0, 0, "sdot", ".2s", ".8b", ".4b">;
|
||||
def UDOTIDX4S : BaseSIMDThreeSameVectorDotIndex<1, 1, "udot", ".4s", ".16b", ".4b">;
|
||||
def SDOTIDX4S : BaseSIMDThreeSameVectorDotIndex<1, 0, "sdot", ".4s", ".16b", ".4b">;
|
||||
defm SDOT : SIMDThreeSameVectorDot<0, "sdot", int_aarch64_neon_sdot>;
|
||||
defm UDOT : SIMDThreeSameVectorDot<1, "udot", int_aarch64_neon_udot>;
|
||||
defm SDOTlane : SIMDThreeSameVectorDotIndex<0, "sdot", int_aarch64_neon_sdot>;
|
||||
defm UDOTlane : SIMDThreeSameVectorDotIndex<1, "udot", int_aarch64_neon_udot>;
|
||||
}
|
||||
|
||||
let Predicates = [HasRCPC] in {
|
||||
|
126
test/CodeGen/AArch64/neon-dot-product.ll
Normal file
126
test/CodeGen/AArch64/neon-dot-product.ll
Normal file
@ -0,0 +1,126 @@
|
||||
; RUN: llc -mtriple aarch64-none-linux-gnu -mattr=+dotprod < %s | FileCheck %s
|
||||
|
||||
declare <2 x i32> @llvm.aarch64.neon.udot.v2i32.v8i8(<2 x i32>, <8 x i8>, <8 x i8>)
|
||||
declare <4 x i32> @llvm.aarch64.neon.udot.v4i32.v16i8(<4 x i32>, <16 x i8>, <16 x i8>)
|
||||
declare <2 x i32> @llvm.aarch64.neon.sdot.v2i32.v8i8(<2 x i32>, <8 x i8>, <8 x i8>)
|
||||
declare <4 x i32> @llvm.aarch64.neon.sdot.v4i32.v16i8(<4 x i32>, <16 x i8>, <16 x i8>)
|
||||
|
||||
define <2 x i32> @test_vdot_u32(<2 x i32> %a, <8 x i8> %b, <8 x i8> %c) #0 {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdot_u32:
|
||||
; CHECK: udot v0.2s, v1.8b, v2.8b
|
||||
%vdot1.i = call <2 x i32> @llvm.aarch64.neon.udot.v2i32.v8i8(<2 x i32> %a, <8 x i8> %b, <8 x i8> %c) #2
|
||||
ret <2 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <4 x i32> @test_vdotq_u32(<4 x i32> %a, <16 x i8> %b, <16 x i8> %c) #0 {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdotq_u32:
|
||||
; CHECK: udot v0.4s, v1.16b, v2.16b
|
||||
%vdot1.i = call <4 x i32> @llvm.aarch64.neon.udot.v4i32.v16i8(<4 x i32> %a, <16 x i8> %b, <16 x i8> %c) #2
|
||||
ret <4 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <2 x i32> @test_vdot_s32(<2 x i32> %a, <8 x i8> %b, <8 x i8> %c) #0 {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdot_s32:
|
||||
; CHECK: sdot v0.2s, v1.8b, v2.8b
|
||||
%vdot1.i = call <2 x i32> @llvm.aarch64.neon.sdot.v2i32.v8i8(<2 x i32> %a, <8 x i8> %b, <8 x i8> %c) #2
|
||||
ret <2 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <4 x i32> @test_vdotq_s32(<4 x i32> %a, <16 x i8> %b, <16 x i8> %c) #0 {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdotq_s32:
|
||||
; CHECK: sdot v0.4s, v1.16b, v2.16b
|
||||
%vdot1.i = call <4 x i32> @llvm.aarch64.neon.sdot.v4i32.v16i8(<4 x i32> %a, <16 x i8> %b, <16 x i8> %c) #2
|
||||
ret <4 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <2 x i32> @test_vdot_lane_u32(<2 x i32> %a, <8 x i8> %b, <8 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdot_lane_u32:
|
||||
; CHECK: udot v0.2s, v1.8b, v2.4b[1]
|
||||
%.cast = bitcast <8 x i8> %c to <2 x i32>
|
||||
%shuffle = shufflevector <2 x i32> %.cast, <2 x i32> undef, <2 x i32> <i32 1, i32 1>
|
||||
%.cast5 = bitcast <2 x i32> %shuffle to <8 x i8>
|
||||
%vdot1.i = call <2 x i32> @llvm.aarch64.neon.udot.v2i32.v8i8(<2 x i32> %a, <8 x i8> %b, <8 x i8> %.cast5) #2
|
||||
ret <2 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <4 x i32> @test_vdotq_lane_u32(<4 x i32> %a, <16 x i8> %b, <8 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdotq_lane_u32:
|
||||
; CHECK: udot v0.4s, v1.16b, v2.4b[1]
|
||||
%.cast = bitcast <8 x i8> %c to <2 x i32>
|
||||
%shuffle = shufflevector <2 x i32> %.cast, <2 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
|
||||
%.cast3 = bitcast <4 x i32> %shuffle to <16 x i8>
|
||||
%vdot1.i = call <4 x i32> @llvm.aarch64.neon.udot.v4i32.v16i8(<4 x i32> %a, <16 x i8> %b, <16 x i8> %.cast3) #2
|
||||
ret <4 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <2 x i32> @test_vdot_laneq_u32(<2 x i32> %a, <8 x i8> %b, <16 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdot_laneq_u32:
|
||||
; CHECK: udot v0.2s, v1.8b, v2.4b[1]
|
||||
%.cast = bitcast <16 x i8> %c to <4 x i32>
|
||||
%shuffle = shufflevector <4 x i32> %.cast, <4 x i32> undef, <2 x i32> <i32 1, i32 1>
|
||||
%.cast5 = bitcast <2 x i32> %shuffle to <8 x i8>
|
||||
%vdot1.i = call <2 x i32> @llvm.aarch64.neon.udot.v2i32.v8i8(<2 x i32> %a, <8 x i8> %b, <8 x i8> %.cast5) #2
|
||||
ret <2 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <4 x i32> @test_vdotq_laneq_u32(<4 x i32> %a, <16 x i8> %b, <16 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdotq_laneq_u32:
|
||||
; CHECK: udot v0.4s, v1.16b, v2.4b[1]
|
||||
%.cast = bitcast <16 x i8> %c to <4 x i32>
|
||||
%shuffle = shufflevector <4 x i32> %.cast, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
|
||||
%.cast3 = bitcast <4 x i32> %shuffle to <16 x i8>
|
||||
%vdot1.i = call <4 x i32> @llvm.aarch64.neon.udot.v4i32.v16i8(<4 x i32> %a, <16 x i8> %b, <16 x i8> %.cast3) #2
|
||||
ret <4 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <2 x i32> @test_vdot_lane_s32(<2 x i32> %a, <8 x i8> %b, <8 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdot_lane_s32:
|
||||
; CHECK: sdot v0.2s, v1.8b, v2.4b[1]
|
||||
%.cast = bitcast <8 x i8> %c to <2 x i32>
|
||||
%shuffle = shufflevector <2 x i32> %.cast, <2 x i32> undef, <2 x i32> <i32 1, i32 1>
|
||||
%.cast5 = bitcast <2 x i32> %shuffle to <8 x i8>
|
||||
%vdot1.i = call <2 x i32> @llvm.aarch64.neon.sdot.v2i32.v8i8(<2 x i32> %a, <8 x i8> %b, <8 x i8> %.cast5) #2
|
||||
ret <2 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <4 x i32> @test_vdotq_lane_s32(<4 x i32> %a, <16 x i8> %b, <8 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdotq_lane_s32:
|
||||
; CHECK: sdot v0.4s, v1.16b, v2.4b[1]
|
||||
%.cast = bitcast <8 x i8> %c to <2 x i32>
|
||||
%shuffle = shufflevector <2 x i32> %.cast, <2 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
|
||||
%.cast3 = bitcast <4 x i32> %shuffle to <16 x i8>
|
||||
%vdot1.i = call <4 x i32> @llvm.aarch64.neon.sdot.v4i32.v16i8(<4 x i32> %a, <16 x i8> %b, <16 x i8> %.cast3) #2
|
||||
ret <4 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <2 x i32> @test_vdot_laneq_s32(<2 x i32> %a, <8 x i8> %b, <16 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdot_laneq_s32:
|
||||
; CHECK: sdot v0.2s, v1.8b, v2.4b[1]
|
||||
%.cast = bitcast <16 x i8> %c to <4 x i32>
|
||||
%shuffle = shufflevector <4 x i32> %.cast, <4 x i32> undef, <2 x i32> <i32 1, i32 1>
|
||||
%.cast5 = bitcast <2 x i32> %shuffle to <8 x i8>
|
||||
%vdot1.i = call <2 x i32> @llvm.aarch64.neon.sdot.v2i32.v8i8(<2 x i32> %a, <8 x i8> %b, <8 x i8> %.cast5) #2
|
||||
ret <2 x i32> %vdot1.i
|
||||
}
|
||||
|
||||
define <4 x i32> @test_vdotq_laneq_s32(<4 x i32> %a, <16 x i8> %b, <16 x i8> %c) {
|
||||
entry:
|
||||
; CHECK-LABEL: test_vdotq_laneq_s32:
|
||||
; CHECK: sdot v0.4s, v1.16b, v2.4b[1]
|
||||
%.cast = bitcast <16 x i8> %c to <4 x i32>
|
||||
%shuffle = shufflevector <4 x i32> %.cast, <4 x i32> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
|
||||
%.cast3 = bitcast <4 x i32> %shuffle to <16 x i8>
|
||||
%vdot1.i = call <4 x i32> @llvm.aarch64.neon.sdot.v4i32.v16i8(<4 x i32> %a, <16 x i8> %b, <16 x i8> %.cast3) #2
|
||||
ret <4 x i32> %vdot1.i
|
||||
}
|
Loading…
Reference in New Issue
Block a user