From f80b349d5490aa289b2925d297f3f3c618977570 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Thu, 27 Nov 2025 17:45:17 +0100 Subject: Unify Lua number to FFI integer conversions. Phew. #1411 --- src/lj_opt_split.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/lj_opt_split.c') diff --git a/src/lj_opt_split.c b/src/lj_opt_split.c index 8d025911..d29d1eab 100644 --- a/src/lj_opt_split.c +++ b/src/lj_opt_split.c @@ -573,13 +573,9 @@ static void split_ir(jit_State *J) case IR_CONV: { /* Conversion to 64 bit integer. Others handled below. */ IRType st = (IRType)(ir->op2 & IRCONV_SRCMASK); #if LJ_SOFTFP + lj_assertJ(st != IRT_FLOAT, "bad CONV *64.float emitted"); if (st == IRT_NUM) { /* NUM to 64 bit int conv. */ - hi = split_call_l(J, hisubst, oir, ir, - irt_isi64(ir->t) ? IRCALL_fp64_d2l : IRCALL_fp64_d2ul); - } else if (st == IRT_FLOAT) { /* FLOAT to 64 bit int conv. */ - nir->o = IR_CALLN; - nir->op2 = irt_isi64(ir->t) ? IRCALL_fp64_f2l : IRCALL_fp64_f2ul; - hi = split_emit(J, IRTI(IR_HIOP), nref, nref); + hi = split_call_l(J, hisubst, oir, ir, IRCALL_lj_vm_num2u64); } #else if (st == IRT_NUM || st == IRT_FLOAT) { /* FP to 64 bit int conv. */ @@ -692,8 +688,9 @@ static void split_ir(jit_State *J) nir->op2 = st == IRT_INT ? IRCALL_softfp_i2f : IRCALL_softfp_ui2f; } } else if (st == IRT_FLOAT) { + lj_assertJ(!irt_isu32(ir->t), "bad CONV u32.fp emitted"); nir->o = IR_CALLN; - nir->op2 = irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui; + nir->op2 = IRCALL_softfp_f2i; } else #endif #if LJ_SOFTFP @@ -705,9 +702,7 @@ static void split_ir(jit_State *J) } else { split_call_l(J, hisubst, oir, ir, #if LJ_32 && LJ_HASFFI - st == IRT_NUM ? - (irt_isint(ir->t) ? IRCALL_softfp_d2i : IRCALL_softfp_d2ui) : - (irt_isint(ir->t) ? IRCALL_softfp_f2i : IRCALL_softfp_f2ui) + st == IRT_NUM ? IRCALL_softfp_d2i : IRCALL_softfp_f2i #else IRCALL_softfp_d2i #endif -- cgit v1.2.3-55-g6feb