diff options
author | Mike Pall <mike> | 2010-12-08 03:33:48 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-12-08 03:33:48 +0100 |
commit | 6a04591b7b319095dcd4800d31d5d1bcb922c76b (patch) | |
tree | 107bf666e7e217321a9d56eba835b26a5d0d2da9 /src | |
parent | 3c78a7f46877e2c151ba7043b2b50d35e09704c5 (diff) | |
download | luajit-6a04591b7b319095dcd4800d31d5d1bcb922c76b.tar.gz luajit-6a04591b7b319095dcd4800d31d5d1bcb922c76b.tar.bz2 luajit-6a04591b7b319095dcd4800d31d5d1bcb922c76b.zip |
FOLD (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz).
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_crecord.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index b197d4b4..c7c99133 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -331,9 +331,21 @@ void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd) | |||
331 | idx = emitir(IRT(IR_TOINT, IRT_INTP), idx, IRTOINT_ANY); | 331 | idx = emitir(IRT(IR_TOINT, IRT_INTP), idx, IRTOINT_ANY); |
332 | #endif | 332 | #endif |
333 | if (ctype_ispointer(ct->info)) { | 333 | if (ctype_ispointer(ct->info)) { |
334 | sid = ctype_cid(ct->info); | 334 | ptrdiff_t sz = (ptrdiff_t)lj_ctype_size(cts, (sid = ctype_cid(ct->info))); |
335 | idx = emitir(IRT(IR_MUL, IRT_INTP), idx, | 335 | IRIns *ir = IR(tref_ref(idx)); |
336 | lj_ir_kintp(J, lj_ctype_size(cts, sid))); | 336 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && |
337 | ir->o == IR_ADD && irref_isk(ir->op2)) { | ||
338 | /* This would be rather difficult in FOLD, so do it here: | ||
339 | ** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz) | ||
340 | */ | ||
341 | idx = ir->op1; | ||
342 | #if LJ_64 | ||
343 | ofs += (int64_t)ir_kint64(IR(ir->op2))->u64 * sz; | ||
344 | #else | ||
345 | ofs += IR(ir->op2)->i * sz; | ||
346 | #endif | ||
347 | } | ||
348 | idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); | ||
337 | ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); | 349 | ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); |
338 | } | 350 | } |
339 | } else if (tref_isstr(idx)) { | 351 | } else if (tref_isstr(idx)) { |