mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Optimize BUFHDR code generation.
Rematerialize const buffer pointer instead of spilling.
This commit is contained in:
parent
068783bf23
commit
723574d08c
14
src/lj_asm.c
14
src/lj_asm.c
@ -1040,7 +1040,19 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref);
|
||||
static void asm_bufhdr(ASMState *as, IRIns *ir)
|
||||
{
|
||||
Reg sb = ra_dest(as, ir, RSET_GPR);
|
||||
if (!(ir->op2 & IRBUFHDR_APPEND)) {
|
||||
if ((ir->op2 & IRBUFHDR_APPEND)) {
|
||||
/* Rematerialize const buffer pointer instead of likely spill. */
|
||||
IRIns *irp = IR(ir->op1);
|
||||
if (!(ra_hasreg(irp->r) || irp == ir-1 ||
|
||||
(irp == ir-2 && !ra_used(ir-1)))) {
|
||||
while (!(irp->o == IR_BUFHDR && !(irp->op2 & IRBUFHDR_APPEND)))
|
||||
irp = IR(irp->op1);
|
||||
if (irref_isk(irp->op1)) {
|
||||
ra_weak(as, ra_allocref(as, ir->op1, RSET_GPR));
|
||||
ir = irp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb));
|
||||
/* Passing ir isn't strictly correct, but it's an IRT_P32, too. */
|
||||
emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p));
|
||||
|
Loading…
Reference in New Issue
Block a user