Optimize table length computation with hinting.

10x faster on loop with t[#t+1] = x idiom. Also used by table.insert.
This commit is contained in:
Mike Pall
2020-05-27 19:20:44 +02:00
parent b2307c8ad8
commit 1a4ff13117
12 changed files with 135 additions and 82 deletions

View File

@@ -352,10 +352,12 @@ static void loop_unroll(LoopState *lps)
irr = IR(ref);
goto phiconv;
}
} else if (ref != REF_DROP && irr->o == IR_CONV &&
ref > invar && irr->op1 < invar) {
/* May need an extra PHI for a CONV. */
ref = irr->op1;
} else if (ref != REF_DROP && ref > invar &&
((irr->o == IR_CONV && irr->op1 < invar) ||
(irr->o == IR_ALEN && irr->op2 < invar &&
irr->op2 != REF_NIL))) {
/* May need an extra PHI for a CONV or ALEN hint. */
ref = irr->o == IR_CONV ? irr->op1 : irr->op2;
irr = IR(ref);
phiconv:
if (ref < invar && !irref_isk(ref) && !irt_isphi(irr->t)) {