Fix fused constant loads under high register pressure.

This commit is contained in:
Mike Pall 2014-10-08 22:04:51 +02:00
parent 4846a714a9
commit 6d0654d3ec
2 changed files with 10 additions and 1 deletions

View File

@ -353,6 +353,7 @@ static Reg ra_rematk(ASMState *as, IRRef ref)
static int32_t ra_spill(ASMState *as, IRIns *ir) static int32_t ra_spill(ASMState *as, IRIns *ir)
{ {
int32_t slot = ir->s; int32_t slot = ir->s;
lua_assert(ir >= as->ir + REF_TRUE);
if (!ra_hasspill(slot)) { if (!ra_hasspill(slot)) {
if (irt_is64(ir->t)) { if (irt_is64(ir->t)) {
slot = as->evenspill; slot = as->evenspill;

View File

@ -325,6 +325,14 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
as->mrm.base = as->mrm.idx = RID_NONE; as->mrm.base = as->mrm.idx = RID_NONE;
return RID_MRM; return RID_MRM;
} }
} else if (ir->o == IR_KINT64) {
RegSet avail = as->freeset & ~as->modset & RSET_GPR;
lua_assert(allow != RSET_EMPTY);
if (!(avail & (avail-1))) { /* Fuse if less than two regs available. */
as->mrm.ofs = ptr2addr(ir_kint64(ir));
as->mrm.base = as->mrm.idx = RID_NONE;
return RID_MRM;
}
} else if (mayfuse(as, ref)) { } else if (mayfuse(as, ref)) {
RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR; RegSet xallow = (allow & RSET_GPR) ? allow : RSET_GPR;
if (ir->o == IR_SLOAD) { if (ir->o == IR_SLOAD) {
@ -361,7 +369,7 @@ static Reg asm_fuseload(ASMState *as, IRRef ref, RegSet allow)
return RID_MRM; return RID_MRM;
} }
} }
if (!(as->freeset & allow) && if (!(as->freeset & allow) && !irref_isk(ref) &&
(allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref))) (allow == RSET_EMPTY || ra_hasspill(ir->s) || iscrossref(as, ref)))
goto fusespill; goto fusespill;
return ra_allocref(as, ref, allow); return ra_allocref(as, ref, allow);