From e4bca9545186ffd6b9ee03f711adfa495d55c0fc Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sun, 28 Mar 2010 06:49:09 +0200 Subject: Generate EQ(HREF, niltv) for load path, too (better CSE). --- src/lj_record.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lj_record.c b/src/lj_record.c index 29c024bf..e89d9c26 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -981,7 +981,13 @@ static TRef rec_idx(jit_State *J, RecordIndex *ix) if (ix->val == 0) { /* Indexed load */ IRType t = itype2irt(oldv); - TRef res = emitir(IRTG(loadop, t), xref, 0); + TRef res; + if (oldv == niltvg(J2G(J))) { + emitir(IRTG(IR_EQ, IRT_PTR), xref, lj_ir_kptr(J, niltvg(J2G(J)))); + res = TREF_NIL; + } else { + res = emitir(IRTG(loadop, t), xref, 0); + } if (t == IRT_NIL && ix->idxchain && rec_mm_lookup(J, ix, MM_index)) goto handlemm; if (irtype_ispri(t)) res = TREF_PRI(t); /* Canonicalize primitives. */ -- cgit v1.2.3-55-g6feb