|
 |
006bc1 |
From 8fc4ce1c981967fccd5366ace6add6d14cfcde89 Mon Sep 17 00:00:00 2001
|
|
 |
006bc1 |
From: Siddhesh Poyarekar <siddhesh@gotplt.org>
|
|
 |
006bc1 |
Date: Mon, 25 Feb 2019 14:40:39 +0000
|
|
 |
006bc1 |
Subject: [PATCH 63/72] aarch64: Use the xzr register whenever possible
|
|
 |
006bc1 |
|
|
 |
006bc1 |
Using the xzr register for store inputs and the second operand of
|
|
 |
006bc1 |
arithmetic operations frees up a register for use elsewhere.
|
|
 |
006bc1 |
---
|
|
 |
006bc1 |
src/lj_asm_arm64.h | 31 ++++++++++++++++++++++++++++---
|
|
 |
006bc1 |
1 file changed, 28 insertions(+), 3 deletions(-)
|
|
 |
006bc1 |
|
|
 |
006bc1 |
diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h
|
|
 |
006bc1 |
index c214e10..a826687 100644
|
|
 |
006bc1 |
--- a/src/lj_asm_arm64.h
|
|
 |
006bc1 |
+++ b/src/lj_asm_arm64.h
|
|
 |
006bc1 |
@@ -1007,10 +1007,30 @@ static void asm_xload(ASMState *as, IRIns *ir)
|
|
 |
006bc1 |
asm_fusexref(as, asm_fxloadins(ir), dest, ir->op1, RSET_GPR);
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
|
|
 |
006bc1 |
+static int maybe_zero_val(ASMState *as, IRRef ref)
|
|
 |
006bc1 |
+{
|
|
 |
006bc1 |
+ IRIns *ir = IR(ref);
|
|
 |
006bc1 |
+
|
|
 |
006bc1 |
+ switch(ir->o) {
|
|
 |
006bc1 |
+ case IR_KNULL:
|
|
 |
006bc1 |
+ return 1;
|
|
 |
006bc1 |
+ case IR_KINT:
|
|
 |
006bc1 |
+ return 0 == ir->i;
|
|
 |
006bc1 |
+ case IR_KINT64:
|
|
 |
006bc1 |
+ return 0 == ir_kint64(ir)->u64;
|
|
 |
006bc1 |
+ }
|
|
 |
006bc1 |
+
|
|
 |
006bc1 |
+ return 0;
|
|
 |
006bc1 |
+}
|
|
 |
006bc1 |
+
|
|
 |
006bc1 |
static void asm_xstore(ASMState *as, IRIns *ir)
|
|
 |
006bc1 |
{
|
|
 |
006bc1 |
if (ir->r != RID_SINK) {
|
|
 |
006bc1 |
- Reg src = ra_alloc1(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
|
|
 |
006bc1 |
+ Reg src;
|
|
 |
006bc1 |
+ if (irref_isk(ir->op2) && maybe_zero_val(as, ir->op2))
|
|
 |
006bc1 |
+ src = RID_ZERO;
|
|
 |
006bc1 |
+ else
|
|
 |
006bc1 |
+ src = ra_alloc1(as, ir->op2, irt_isfp(ir->t) ? RSET_FPR : RSET_GPR);
|
|
 |
006bc1 |
asm_fusexref(as, asm_fxstoreins(ir), src, ir->op1,
|
|
 |
006bc1 |
rset_exclude(RSET_GPR, src));
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
@@ -1198,7 +1218,12 @@ static void asm_cnew(ASMState *as, IRIns *ir)
|
|
 |
006bc1 |
/* Initialize immutable cdata object. */
|
|
 |
006bc1 |
if (ir->o == IR_CNEWI) {
|
|
 |
006bc1 |
int32_t ofs = sizeof(GCcdata);
|
|
 |
006bc1 |
- Reg r = ra_alloc1(as, ir->op2, allow);
|
|
 |
006bc1 |
+ Reg r;
|
|
 |
006bc1 |
+ if (irref_isk(ir->op2) && maybe_zero_val(as, ir->op2))
|
|
 |
006bc1 |
+ r = RID_ZERO;
|
|
 |
006bc1 |
+ else
|
|
 |
006bc1 |
+ r = ra_alloc1(as, ir->op2, allow);
|
|
 |
006bc1 |
+
|
|
 |
006bc1 |
lua_assert(sz == 4 || sz == 8);
|
|
 |
006bc1 |
emit_lso(as, sz == 8 ? A64I_STRx : A64I_STRw, r, RID_RET, ofs);
|
|
 |
006bc1 |
} else if (ir->op2 != REF_NIL) { /* Create VLA/VLS/aligned cdata. */
|
|
 |
006bc1 |
@@ -1214,7 +1239,7 @@ static void asm_cnew(ASMState *as, IRIns *ir)
|
|
 |
006bc1 |
|
|
 |
006bc1 |
/* Initialize gct and ctypeid. lj_mem_newgco() already sets marked. */
|
|
 |
006bc1 |
{
|
|
 |
006bc1 |
- Reg r = (id < 65536) ? RID_X1 : ra_allock(as, id, allow);
|
|
 |
006bc1 |
+ Reg r = id == 0 ? RID_ZERO : (id < 65536) ? RID_X1 : ra_allock(as, id, allow);
|
|
 |
006bc1 |
emit_lso(as, A64I_STRB, RID_TMP, RID_RET, offsetof(GCcdata, gct));
|
|
 |
006bc1 |
emit_lso(as, A64I_STRH, r, RID_RET, offsetof(GCcdata, ctypeid));
|
|
 |
006bc1 |
emit_d(as, A64I_MOVZw | A64F_U16(~LJ_TCDATA), RID_TMP);
|
|
 |
006bc1 |
--
|
|
 |
006bc1 |
2.20.1
|
|
 |
006bc1 |
|