Fix check for reuse of SCEV results in FORL.

This commit is contained in:
Mike Pall 2014-03-27 23:29:30 +01:00
parent c03be1210c
commit 095344ce7c
2 changed files with 4 additions and 1 deletions

View File

@ -279,6 +279,7 @@ typedef struct BPropEntry {
/* Scalar evolution analysis cache. */
typedef struct ScEvEntry {
MRef pc; /* Bytecode PC of FORI. */
IRRef1 idx; /* Index reference. */
IRRef1 start; /* Constant start reference. */
IRRef1 stop; /* Constant stop reference. */

View File

@ -421,6 +421,7 @@ static void rec_for_loop(jit_State *J, const BCIns *fori, ScEvEntry *scev,
J->base[ra+FORL_IDX] = idx = emitir(IRT(IR_ADD, t), idx, step);
J->base[ra+FORL_EXT] = idx;
scev->idx = tref_ref(idx);
setmref(scev->pc, fori);
J->maxslot = ra+FORL_EXT+1;
}
@ -436,7 +437,7 @@ static LoopEvent rec_for(jit_State *J, const BCIns *fori, int isforl)
IRType t;
if (isforl) { /* Handle FORL/JFORL opcodes. */
TRef idx = tr[FORL_IDX];
if (tref_ref(idx) == J->scev.idx) {
if (mref(J->scev.pc, const BCIns) == fori) {
t = J->scev.t.irt;
stop = J->scev.stop;
idx = emitir(IRT(IR_ADD, t), idx, J->scev.step);
@ -2153,6 +2154,7 @@ void lj_record_setup(jit_State *J)
memset(J->chain, 0, sizeof(J->chain));
memset(J->bpropcache, 0, sizeof(J->bpropcache));
J->scev.idx = REF_NIL;
setmref(J->scev.pc, NULL);
J->baseslot = 1; /* Invoking function is at base[-1]. */
J->base = J->slot + J->baseslot;