Skip to content

Commit b78f55f

Browse files
sunlijun-610pull[bot]
authored andcommitted
[LoongArch64] Fix code generation for type conversion from float/double to uint/ulong. (#105783)
* [LoongArch64] Fix code generation for type conversion from float/double to uint/ulong. * Modify the code format.
1 parent d824ab9 commit b78f55f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/coreclr/jit/codegenloongarch64.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,6 +3179,14 @@ void CodeGen::genFloatToIntCast(GenTree* treeNode)
31793179
}
31803180
}
31813181

3182+
GetEmitter()->emitIns_R_R_I(INS_ori, dstSize, treeNode->GetRegNum(), REG_R0, 0);
3183+
3184+
GetEmitter()->emitIns_R_R(srcType == TYP_DOUBLE ? INS_movgr2fr_d : INS_movgr2fr_w, EA_8BYTE, tmpReg, REG_R0);
3185+
3186+
GetEmitter()->emitIns_R_R_I(srcType == TYP_DOUBLE ? INS_fcmp_cult_d : INS_fcmp_cult_s, EA_8BYTE,
3187+
op1->GetRegNum(), tmpReg, 2); // cc=2
3188+
GetEmitter()->emitIns_I_I(INS_bcnez, EA_PTRSIZE, 2, dstType == TYP_UINT ? 16 << 2 : 13 << 2); // cc=2
3189+
31823190
if (srcType == TYP_DOUBLE)
31833191
{
31843192
GetEmitter()->emitIns_R_R_I(INS_lu52i_d, EA_8BYTE, REG_R21, REG_R0, imm >> 8);
@@ -3193,9 +3201,6 @@ void CodeGen::genFloatToIntCast(GenTree* treeNode)
31933201
GetEmitter()->emitIns_R_R_I(srcType == TYP_DOUBLE ? INS_fcmp_clt_d : INS_fcmp_clt_s, EA_8BYTE, op1->GetRegNum(),
31943202
tmpReg, 2); // cc=2
31953203

3196-
GetEmitter()->emitIns_R_R_I(srcType == TYP_DOUBLE ? INS_fcmp_ceq_d : INS_fcmp_ceq_s, EA_8BYTE, op1->GetRegNum(),
3197-
tmpReg, 3); // cc=3
3198-
31993204
GetEmitter()->emitIns_R_R_I(INS_ori, EA_PTRSIZE, REG_R21, REG_R0, 0);
32003205
GetEmitter()->emitIns_I_I(INS_bcnez, EA_PTRSIZE, 2, 4 << 2); // cc=2
32013206

@@ -3218,9 +3223,6 @@ void CodeGen::genFloatToIntCast(GenTree* treeNode)
32183223
GetEmitter()->emitIns_R_R_I(INS_ori, dstSize, treeNode->GetRegNum(), REG_R0, 0);
32193224
}
32203225

3221-
GetEmitter()->emitIns_I_I(INS_bcnez, EA_PTRSIZE, 3, 2 << 2); // cc=3
3222-
GetEmitter()->emitIns_R_I(INS_beqz, EA_PTRSIZE, treeNode->GetRegNum(), 2 << 2);
3223-
32243226
GetEmitter()->emitIns_R_R_R(INS_or, dstSize, treeNode->GetRegNum(), REG_R21, treeNode->GetRegNum());
32253227
}
32263228
else

0 commit comments

Comments
 (0)