aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2023-12-23 19:14:32 +0100
committerMike Pall <mike>2023-12-23 19:14:32 +0100
commitc42c62e71a45a677b8b1cbf749bd33cf4d5918ff (patch)
tree9d51293298d3f0dad3f5b42a461ed374b3fd1e49
parent9bdfd34dccb913777be0efcc6869b6eeb5b9b43b (diff)
downloadluajit-c42c62e71a45a677b8b1cbf749bd33cf4d5918ff.tar.gz
luajit-c42c62e71a45a677b8b1cbf749bd33cf4d5918ff.tar.bz2
luajit-c42c62e71a45a677b8b1cbf749bd33cf4d5918ff.zip
Simplify handling of instable types in TNEW/TDUP load forwarding.
Thanks to Peter Cawley. #994
-rw-r--r--src/lj_opt_mem.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c
index dc74a06d..04b95a6f 100644
--- a/src/lj_opt_mem.c
+++ b/src/lj_opt_mem.c
@@ -185,25 +185,23 @@ static TRef fwd_ahload(jit_State *J, IRRef xref)
185 } 185 }
186 ref = store->prev; 186 ref = store->prev;
187 } 187 }
188 if (ir->o == IR_TNEW && !irt_isnil(fins->t)) 188 /* Simplified here: let loop_unroll() figure out any type instability. */
189 return 0; /* Type instability in loop-carried dependency. */ 189 if (ir->o == IR_TNEW) {
190 if (irt_ispri(fins->t)) { 190 return TREF_NIL;
191 return TREF_PRI(irt_type(fins->t)); 191 } else {
192 } else if (irt_isnum(fins->t) || (LJ_DUALNUM && irt_isint(fins->t)) ||
193 irt_isstr(fins->t)) {
194 TValue keyv; 192 TValue keyv;
195 cTValue *tv; 193 cTValue *tv;
196 IRIns *key = IR(xr->op2); 194 IRIns *key = IR(xr->op2);
197 if (key->o == IR_KSLOT) key = IR(key->op1); 195 if (key->o == IR_KSLOT) key = IR(key->op1);
198 lj_ir_kvalue(J->L, &keyv, key); 196 lj_ir_kvalue(J->L, &keyv, key);
199 tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv); 197 tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv);
200 if (itype2irt(tv) != irt_type(fins->t)) 198 if (tvispri(tv))
201 return 0; /* Type instability in loop-carried dependency. */ 199 return TREF_PRI(itype2irt(tv));
202 if (irt_isnum(fins->t)) 200 else if (tvisnum(tv))
203 return lj_ir_knum_u64(J, tv->u64); 201 return lj_ir_knum_u64(J, tv->u64);
204 else if (LJ_DUALNUM && irt_isint(fins->t)) 202 else if (tvisint(tv))
205 return lj_ir_kint(J, intV(tv)); 203 return lj_ir_kint(J, intV(tv));
206 else 204 else if (tvisgcv(tv))
207 return lj_ir_kstr(J, strV(tv)); 205 return lj_ir_kstr(J, strV(tv));
208 } 206 }
209 /* Othwerwise: don't intern as a constant. */ 207 /* Othwerwise: don't intern as a constant. */