]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
MIPS64 R2/R6: Fix FP to integer conversions.
authorMike Pall <mike>
Mon, 22 Jan 2024 18:12:13 +0000 (19:12 +0100)
committerMike Pall <mike>
Mon, 22 Jan 2024 18:12:13 +0000 (19:12 +0100)
Thanks to Peter Cawley. #1146

src/lj_asm_mips.h

index d4e40c912dd2c1c80f3d606bfd2b452f4c6250fe..5b83e34d0d96b522e39646b73bc7914038f1c6e2 100644 (file)
@@ -653,11 +653,11 @@ static void asm_conv(ASMState *as, IRIns *ir)
                     rset_exclude(RSET_GPR, dest));
          emit_fg(as, MIPSI_TRUNC_L_D, tmp, left);  /* Delay slot. */
 #if !LJ_TARGET_MIPSR6
-        emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
-        emit_fgh(as, MIPSI_C_OLT_D, 0, left, tmp);
+       emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
+       emit_fgh(as, MIPSI_C_OLT_D, 0, left, tmp);
 #else
-        emit_branch(as, MIPSI_BC1NEZ, 0, (left&31), l_end);
-        emit_fgh(as, MIPSI_CMP_LT_D, left, left, tmp);
+       emit_branch(as, MIPSI_BC1NEZ, 0, (tmp&31), l_end);
+       emit_fgh(as, MIPSI_CMP_LT_D, tmp, left, tmp);
 #endif
          emit_lsptr(as, MIPSI_LDC1, (tmp & 31),
                     (void *)&as->J->k64[LJ_K64_2P63],
@@ -670,11 +670,11 @@ static void asm_conv(ASMState *as, IRIns *ir)
                     rset_exclude(RSET_GPR, dest));
          emit_fg(as, MIPSI_TRUNC_L_S, tmp, left);  /* Delay slot. */
 #if !LJ_TARGET_MIPSR6
-        emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
-        emit_fgh(as, MIPSI_C_OLT_S, 0, left, tmp);
+       emit_branch(as, MIPSI_BC1T, 0, 0, l_end);
+       emit_fgh(as, MIPSI_C_OLT_S, 0, left, tmp);
 #else
-        emit_branch(as, MIPSI_BC1NEZ, 0, (left&31), l_end);
-        emit_fgh(as, MIPSI_CMP_LT_S, left, left, tmp);
+       emit_branch(as, MIPSI_BC1NEZ, 0, (tmp&31), l_end);
+       emit_fgh(as, MIPSI_CMP_LT_S, tmp, left, tmp);
 #endif
          emit_lsptr(as, MIPSI_LWC1, (tmp & 31),
                     (void *)&as->J->k32[LJ_K32_2P63],
@@ -690,8 +690,8 @@ static void asm_conv(ASMState *as, IRIns *ir)
        MIPSIns mi = irt_is64(ir->t) ?
          (st == IRT_NUM ? MIPSI_TRUNC_L_D : MIPSI_TRUNC_L_S) :
          (st == IRT_NUM ? MIPSI_TRUNC_W_D : MIPSI_TRUNC_W_S);
-       emit_tg(as, irt_is64(ir->t) ? MIPSI_DMFC1 : MIPSI_MFC1, dest, left);
-       emit_fg(as, mi, left, left);
+       emit_tg(as, irt_is64(ir->t) ? MIPSI_DMFC1 : MIPSI_MFC1, dest, tmp);
+       emit_fg(as, mi, tmp, left);
 #endif
       }
     }