mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-08 07:34:07 +00:00
FOLD (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz).
This commit is contained in:
parent
3c78a7f468
commit
6a04591b7b
@ -331,9 +331,21 @@ void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd)
|
|||||||
idx = emitir(IRT(IR_TOINT, IRT_INTP), idx, IRTOINT_ANY);
|
idx = emitir(IRT(IR_TOINT, IRT_INTP), idx, IRTOINT_ANY);
|
||||||
#endif
|
#endif
|
||||||
if (ctype_ispointer(ct->info)) {
|
if (ctype_ispointer(ct->info)) {
|
||||||
sid = ctype_cid(ct->info);
|
ptrdiff_t sz = (ptrdiff_t)lj_ctype_size(cts, (sid = ctype_cid(ct->info)));
|
||||||
idx = emitir(IRT(IR_MUL, IRT_INTP), idx,
|
IRIns *ir = IR(tref_ref(idx));
|
||||||
lj_ir_kintp(J, lj_ctype_size(cts, sid)));
|
if (LJ_LIKELY(J->flags & JIT_F_OPT_FOLD) &&
|
||||||
|
ir->o == IR_ADD && irref_isk(ir->op2)) {
|
||||||
|
/* This would be rather difficult in FOLD, so do it here:
|
||||||
|
** (base+(idx+k)*sz)+ofs ==> (base+idx*sz)+(ofs+k*sz)
|
||||||
|
*/
|
||||||
|
idx = ir->op1;
|
||||||
|
#if LJ_64
|
||||||
|
ofs += (int64_t)ir_kint64(IR(ir->op2))->u64 * sz;
|
||||||
|
#else
|
||||||
|
ofs += IR(ir->op2)->i * sz;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
idx = emitir(IRT(IR_MUL, IRT_INTP), idx, lj_ir_kintp(J, sz));
|
||||||
ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr);
|
ptr = emitir(IRT(IR_ADD, IRT_PTR), idx, ptr);
|
||||||
}
|
}
|
||||||
} else if (tref_isstr(idx)) {
|
} else if (tref_isstr(idx)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user