|
 |
006bc1 |
From e99ac1bc2df5c1d138bbc98d35d1a1892144cf2b Mon Sep 17 00:00:00 2001
|
|
 |
006bc1 |
From: Sameera Deshpande <sameera.deshpande@linaro.org>
|
|
 |
006bc1 |
Date: Fri, 15 Feb 2019 07:46:16 +0530
|
|
 |
006bc1 |
Subject: [PATCH 65/72] Add support for FNMADD and FNMSUB.
|
|
 |
006bc1 |
|
|
 |
006bc1 |
---
|
|
 |
006bc1 |
src/lj_asm_arm64.h | 32 +++++++++++++++++++++++++++++++-
|
|
 |
006bc1 |
1 file changed, 31 insertions(+), 1 deletion(-)
|
|
 |
006bc1 |
|
|
 |
006bc1 |
diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h
|
|
 |
006bc1 |
index a826687..470e65d 100644
|
|
 |
006bc1 |
--- a/src/lj_asm_arm64.h
|
|
 |
006bc1 |
+++ b/src/lj_asm_arm64.h
|
|
 |
006bc1 |
@@ -344,6 +344,35 @@ static int asm_fusemadd(ASMState *as, IRIns *ir, A64Ins ai, A64Ins air)
|
|
 |
006bc1 |
return 0;
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
|
|
 |
006bc1 |
+/* Fuse FP neg-multiply-add/sub. */
|
|
 |
006bc1 |
+static int asm_fusenmadd(ASMState *as, IRIns *ir, A64Ins ai, A64Ins air)
|
|
 |
006bc1 |
+{
|
|
 |
006bc1 |
+ IRRef ref = ir->op1;
|
|
 |
006bc1 |
+ IRIns *irn = IR(ref);
|
|
 |
006bc1 |
+ if (irn->o != IR_ADD && irn->o != IR_SUB)
|
|
 |
006bc1 |
+ return 0;
|
|
 |
006bc1 |
+
|
|
 |
006bc1 |
+ if (!mayfuse(as, ref))
|
|
 |
006bc1 |
+ return 0;
|
|
 |
006bc1 |
+
|
|
 |
006bc1 |
+ IRRef lref = irn->op1, rref = irn->op2;
|
|
 |
006bc1 |
+ IRIns *irm;
|
|
 |
006bc1 |
+ if (lref != rref &&
|
|
 |
006bc1 |
+ ((mayfuse(as, lref) && (irm = IR(lref), irm->o == IR_MUL) &&
|
|
 |
006bc1 |
+ ra_noreg(irm->r)) ||
|
|
 |
006bc1 |
+ (mayfuse(as, rref) && (irm = IR(rref), irm->o == IR_MUL) &&
|
|
 |
006bc1 |
+ (rref = lref, ra_noreg(irm->r))))) {
|
|
 |
006bc1 |
+ Reg dest = ra_dest(as, ir, RSET_FPR);
|
|
 |
006bc1 |
+ Reg add = ra_hintalloc(as, rref, dest, RSET_FPR);
|
|
 |
006bc1 |
+ Reg left = ra_alloc2(as, irm,
|
|
 |
006bc1 |
+ rset_exclude(rset_exclude(RSET_FPR, dest), add));
|
|
 |
006bc1 |
+ Reg right = (left >> 8); left &= 255;
|
|
 |
006bc1 |
+ emit_dnma(as, (irn->o == IR_ADD ? ai : air), (dest & 31), (left & 31), (right & 31), (add & 31));
|
|
 |
006bc1 |
+ return 1;
|
|
 |
006bc1 |
+ }
|
|
 |
006bc1 |
+ return 0;
|
|
 |
006bc1 |
+}
|
|
 |
006bc1 |
+
|
|
 |
006bc1 |
/* Fuse BAND + BSHL/BSHR into UBFM. */
|
|
 |
006bc1 |
static int asm_fuseandshift(ASMState *as, IRIns *ir)
|
|
 |
006bc1 |
{
|
|
 |
006bc1 |
@@ -1481,7 +1510,8 @@ static void asm_mod(ASMState *as, IRIns *ir)
|
|
 |
006bc1 |
static void asm_neg(ASMState *as, IRIns *ir)
|
|
 |
006bc1 |
{
|
|
 |
006bc1 |
if (irt_isnum(ir->t)) {
|
|
 |
006bc1 |
- asm_fpunary(as, ir, A64I_FNEGd);
|
|
 |
006bc1 |
+ if (!asm_fusenmadd(as, ir, A64I_FNMADDd))
|
|
 |
006bc1 |
+ asm_fpunary(as, ir, A64I_FNEGd);
|
|
 |
006bc1 |
return;
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
asm_intneg(as, ir);
|
|
 |
006bc1 |
--
|
|
 |
006bc1 |
2.20.1
|
|
 |
006bc1 |
|