From 66a100617566ee710da85d01c5db21c65ba214b4 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 5 Apr 2011 16:32:27 +0200 Subject: [PATCH] Fuse XLOAD/XSTORE operands more aggressively. --- src/lj_asm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lj_asm.c b/src/lj_asm.c index 8af05e5a..a69f4461 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -97,6 +97,7 @@ typedef struct ASMState { #define FUSE_DISABLED (~(IRRef)0) #define mayfuse(as, ref) ((ref) > as->fuseref) #define neverfuse(as) (as->fuseref == FUSE_DISABLED) +#define canfuse(as, ir) (!neverfuse(as) && !irt_isphi((ir)->t)) #define opisfusableload(o) \ ((o) == IR_ALOAD || (o) == IR_HLOAD || (o) == IR_ULOAD || \ (o) == IR_FLOAD || (o) == IR_XLOAD || (o) == IR_SLOAD || (o) == IR_VLOAD) @@ -1348,7 +1349,7 @@ static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow) asm_fusestrref(as, ir, allow); } else { as->mrm.ofs = 0; - if (mayfuse(as, ref) && ir->o == IR_ADD && ra_noreg(ir->r)) { + if (canfuse(as, ir) && ir->o == IR_ADD && ra_noreg(ir->r)) { /* Gather (base+idx*sz)+ofs as emitted by cdata ptr/array indexing. */ IRIns *irx; IRRef idx; @@ -1356,7 +1357,7 @@ static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow) if (asm_isk32(as, ir->op2, &as->mrm.ofs)) { /* Recognize x+ofs. */ ref = ir->op1; ir = IR(ref); - if (!(ir->o == IR_ADD && mayfuse(as, ref) && ra_noreg(ir->r))) + if (!(ir->o == IR_ADD && canfuse(as, ir) && ra_noreg(ir->r))) goto noadd; } as->mrm.scale = XM_SCALE1; @@ -1368,7 +1369,7 @@ static void asm_fusexref(ASMState *as, IRRef ref, RegSet allow) ref = ir->op1; irx = IR(idx); } - if (mayfuse(as, idx) && ra_noreg(irx->r)) { + if (canfuse(as, irx) && ra_noreg(irx->r)) { if (irx->o == IR_BSHL && irref_isk(irx->op2) && IR(irx->op2)->i <= 3) { /* Recognize idx<op1;