1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

[Hexagon] Converting multiply and accumulate with immediate intrinsics to patterns.

llvm-svn: 226681
This commit is contained in:
Colin LeMahieu 2015-01-21 18:13:15 +00:00
parent aea688cba4
commit eacab3ed87
2 changed files with 141 additions and 0 deletions

View File

@ -53,6 +53,10 @@ class T_QIR_pat <InstHexagon MI, Intrinsic IntID, PatFrag ImmPred>
: Pat <(IntID (i32 PredRegs:$Ps), ImmPred:$Is, I32:$Rs),
(MI PredRegs:$Ps, ImmPred:$Is, I32:$Rs)>;
class T_RRI_pat <InstHexagon MI, Intrinsic IntID>
: Pat <(IntID I32:$Rs, I32:$Rt, imm:$Iu),
(MI I32:$Rs, I32:$Rt, imm:$Iu)>;
class T_RRR_pat <InstHexagon MI, Intrinsic IntID>
: Pat <(IntID I32:$Rs, I32:$Rt, I32:$Ru),
(MI I32:$Rs, I32:$Rt, I32:$Ru)>;
@ -333,6 +337,23 @@ def: T_PP_pat<A2_xorp, int_hexagon_A2_xorp>;
def: T_PP_pat<S2_parityp, int_hexagon_S2_parityp>;
def: T_RR_pat<S2_packhl, int_hexagon_S2_packhl>;
// Multiply 32x32 and use lower result
def : T_RRI_pat <M2_macsip, int_hexagon_M2_macsip>;
def : T_RRI_pat <M2_macsin, int_hexagon_M2_macsin>;
def : T_RRR_pat <M2_maci, int_hexagon_M2_maci>;
// Subtract and accumulate
def : T_RRR_pat <M2_subacc, int_hexagon_M2_subacc>;
// Add and accumulate
def : T_RRR_pat <M2_acci, int_hexagon_M2_acci>;
def : T_RRR_pat <M2_nacci, int_hexagon_M2_nacci>;
def : T_RRI_pat <M2_accii, int_hexagon_M2_accii>;
def : T_RRI_pat <M2_naccii, int_hexagon_M2_naccii>;
// XOR and XOR with destination
def : T_RRR_pat <M2_xor_xacc, int_hexagon_M2_xor_xacc>;
//
// ALU 32 types.
//

View File

@ -0,0 +1,120 @@
; RUN: llc -march=hexagon -mcpu=hexagonv5 < %s | FileCheck %s
; Verify that the mpy intrinsics with add/subtract are being lowered to the right instruction.
@c = external global i64
; CHECK: r{{[0-9]+}}{{ *}}+{{ *}}={{ *}}mpyi(r{{[0-9]+}}{{ *}},{{ *}}#124)
define void @test1(i32 %a) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.macsip(i32 %conv, i32 %a, i32 124)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.macsip(i32, i32, i32) #1
; CHECK: r{{[0-9]+}}{{ *}}-{{ *}}={{ *}}mpyi(r{{[0-9]+}}{{ *}},{{ *}}#166)
define void @test2(i32 %a) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.macsin(i32 %conv, i32 %a, i32 166)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.macsin(i32, i32, i32) #1
; CHECK: r{{[0-9]+}}{{ *}}+{{ *}}={{ *}}mpyi(r{{[0-9]+}}{{ *}},{{ *}}r{{[0-9]+}})
define void @test3(i32 %a, i32 %b) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.maci(i32 %conv, i32 %a, i32 %b)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.maci(i32, i32, i32) #1
@d = external global i32
; CHECK: r{{[0-9]+}}{{ *}}+{{ *}}={{ *}}add(r{{[0-9]+}}{{ *}},{{ *}}#40)
define void @test7(i32 %a) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.accii(i32 %conv, i32 %a, i32 40)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.accii(i32, i32, i32) #1
; CHECK: r{{[0-9]+}}{{ *}}-{{ *}}={{ *}}add(r{{[0-9]+}}{{ *}},{{ *}}#100)
define void @test8(i32 %a) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.naccii(i32 %conv, i32 %a, i32 100)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.naccii(i32, i32, i32) #1
; CHECK: r{{[0-9]+}}{{ *}}+{{ *}}={{ *}}add(r{{[0-9]+}}{{ *}},{{ *}}r{{[0-9]+}})
define void @test9(i32 %a, i32 %b) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.acci(i32 %conv, i32 %a, i32 %b)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.acci(i32, i32, i32) #1
; CHECK: r{{[0-9]+}}{{ *}}+{{ *}}={{ *}}sub(r{{[0-9]+}}{{ *}},{{ *}}r{{[0-9]+}})
define void @test10(i32 %a, i32 %b) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.subacc(i32 %conv, i32 %a, i32 %b)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.subacc(i32, i32, i32) #1
; CHECK: r{{[0-9]+}}{{ *}}-{{ *}}={{ *}}add(r{{[0-9]+}}{{ *}},{{ *}}r{{[0-9]+}})
define void @test11(i32 %a, i32 %b) #0 {
entry:
%0 = load i64* @c, align 8
%conv = trunc i64 %0 to i32
%1 = tail call i32 @llvm.hexagon.M2.nacci(i32 %conv, i32 %a, i32 %b)
%conv1 = sext i32 %1 to i64
store i64 %conv1, i64* @c, align 8
ret void
}
declare i32 @llvm.hexagon.M2.nacci(i32, i32, i32) #1