diff options
author | Mike Pall <mike> | 2013-04-27 00:17:59 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2013-04-27 00:17:59 +0200 |
commit | 723574d08cf9f902bd917e83d8fe25717690b0c6 (patch) | |
tree | 2764bdffae20f8de9e2a58d3ede70e62b2791389 | |
parent | 068783bf23ff173e188974b6479503cad15d0952 (diff) | |
download | luajit-723574d08cf9f902bd917e83d8fe25717690b0c6.tar.gz luajit-723574d08cf9f902bd917e83d8fe25717690b0c6.tar.bz2 luajit-723574d08cf9f902bd917e83d8fe25717690b0c6.zip |
Optimize BUFHDR code generation.
Rematerialize const buffer pointer instead of spilling.
-rw-r--r-- | src/lj_asm.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c index 73df6850..b8d20f2d 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c | |||
@@ -1040,7 +1040,19 @@ static void asm_tvptr(ASMState *as, Reg dest, IRRef ref); | |||
1040 | static void asm_bufhdr(ASMState *as, IRIns *ir) | 1040 | static void asm_bufhdr(ASMState *as, IRIns *ir) |
1041 | { | 1041 | { |
1042 | Reg sb = ra_dest(as, ir, RSET_GPR); | 1042 | Reg sb = ra_dest(as, ir, RSET_GPR); |
1043 | if (!(ir->op2 & IRBUFHDR_APPEND)) { | 1043 | if ((ir->op2 & IRBUFHDR_APPEND)) { |
1044 | /* Rematerialize const buffer pointer instead of likely spill. */ | ||
1045 | IRIns *irp = IR(ir->op1); | ||
1046 | if (!(ra_hasreg(irp->r) || irp == ir-1 || | ||
1047 | (irp == ir-2 && !ra_used(ir-1)))) { | ||
1048 | while (!(irp->o == IR_BUFHDR && !(irp->op2 & IRBUFHDR_APPEND))) | ||
1049 | irp = IR(irp->op1); | ||
1050 | if (irref_isk(irp->op1)) { | ||
1051 | ra_weak(as, ra_allocref(as, ir->op1, RSET_GPR)); | ||
1052 | ir = irp; | ||
1053 | } | ||
1054 | } | ||
1055 | } else { | ||
1044 | Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb)); | 1056 | Reg tmp = ra_scratch(as, rset_exclude(RSET_GPR, sb)); |
1045 | /* Passing ir isn't strictly correct, but it's an IRT_P32, too. */ | 1057 | /* Passing ir isn't strictly correct, but it's an IRT_P32, too. */ |
1046 | emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p)); | 1058 | emit_storeofs(as, ir, tmp, sb, offsetof(SBuf, p)); |