Simplify handling of instable types in TNEW/TDUP load forwarding.

Thanks to Peter Cawley. #994
This commit is contained in:
Mike Pall 2023-12-23 19:14:32 +01:00
parent 9bdfd34dcc
commit c42c62e71a

View File

@ -185,25 +185,23 @@ static TRef fwd_ahload(jit_State *J, IRRef xref)
} }
ref = store->prev; ref = store->prev;
} }
if (ir->o == IR_TNEW && !irt_isnil(fins->t)) /* Simplified here: let loop_unroll() figure out any type instability. */
return 0; /* Type instability in loop-carried dependency. */ if (ir->o == IR_TNEW) {
if (irt_ispri(fins->t)) { return TREF_NIL;
return TREF_PRI(irt_type(fins->t)); } else {
} else if (irt_isnum(fins->t) || (LJ_DUALNUM && irt_isint(fins->t)) ||
irt_isstr(fins->t)) {
TValue keyv; TValue keyv;
cTValue *tv; cTValue *tv;
IRIns *key = IR(xr->op2); IRIns *key = IR(xr->op2);
if (key->o == IR_KSLOT) key = IR(key->op1); if (key->o == IR_KSLOT) key = IR(key->op1);
lj_ir_kvalue(J->L, &keyv, key); lj_ir_kvalue(J->L, &keyv, key);
tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv); tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv);
if (itype2irt(tv) != irt_type(fins->t)) if (tvispri(tv))
return 0; /* Type instability in loop-carried dependency. */ return TREF_PRI(itype2irt(tv));
if (irt_isnum(fins->t)) else if (tvisnum(tv))
return lj_ir_knum_u64(J, tv->u64); return lj_ir_knum_u64(J, tv->u64);
else if (LJ_DUALNUM && irt_isint(fins->t)) else if (tvisint(tv))
return lj_ir_kint(J, intV(tv)); return lj_ir_kint(J, intV(tv));
else else if (tvisgcv(tv))
return lj_ir_kstr(J, strV(tv)); return lj_ir_kstr(J, strV(tv));
} }
/* Othwerwise: don't intern as a constant. */ /* Othwerwise: don't intern as a constant. */