diff options
Diffstat (limited to 'src/lj_crecord.c')
-rw-r--r-- | src/lj_crecord.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index c7c99133..566c064b 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -335,15 +335,17 @@ void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd) | |||
335 | IRIns *ir = IR(tref_ref(idx)); | 335 | IRIns *ir = IR(tref_ref(idx)); |
336 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && | 336 | if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) && |
337 | ir->o == IR_ADD && irref_isk(ir->op2)) { | 337 | ir->o == IR_ADD && irref_isk(ir->op2)) { |
338 | IRIns *irk = IR(ir->op2); | ||
339 | idx = ir->op1; | ||
338 | /* This would be rather difficult in FOLD, so do it here: | 340 | /* This would be rather difficult in FOLD, so do it here: |
339 | ** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz) | 341 | ** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz) |
340 | */ | 342 | */ |
341 | idx = ir->op1; | ||
342 | #if LJ_64 | 343 | #if LJ_64 |
343 | ofs += (int64_t)ir_kint64(IR(ir->op2))->u64 * sz; | 344 | if (irk->o == IR_KINT64) |
344 | #else | 345 | ofs += (ptrdiff_t)ir_kint64(irk)->u64 * sz; |
345 | ofs += IR(ir->op2)->i * sz; | 346 | else |
346 | #endif | 347 | #endif |
348 | ofs += (ptrdiff_t)irk->i * sz; | ||
347 | } | 349 | } |
348 | idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); | 350 | idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz)); |
349 | ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); | 351 | ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr); |