Skip to content

Commit

Permalink
[RISC-V][JIT] Fix arithmetics (dotnet#86996)
Browse files Browse the repository at this point in the history
* [RISC-V][JIT] Fix multiplication instruction

* [RISC-V][JIT] Fix a test failure

- value_numbering_checked_arithmetic_with_constants_ro
  • Loading branch information
clamp03 committed Jun 6, 2023
1 parent e96321d commit f026bb0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3729,21 +3729,25 @@ void CodeGen::genCodeForJumpCompare(GenTreeOpCC* tree)
switch (cmpSize)
{
case EA_4BYTE:
{
regNumber tmpRegOp1 = rsGetRsvdReg();
assert(regOp1 != tmpRegOp1);
if (cond.IsUnsigned())
{
imm = static_cast<uint32_t>(imm);

regNumber tmpRegOp1 = rsGetRsvdReg();
assert(regOp1 != tmpRegOp1);
emit->emitIns_R_R_I(INS_slli, EA_8BYTE, tmpRegOp1, regOp1, 32);
emit->emitIns_R_R_I(INS_srli, EA_8BYTE, tmpRegOp1, tmpRegOp1, 32);
regOp1 = tmpRegOp1;
}
else
{
imm = static_cast<int32_t>(imm);
emit->emitIns_R_R_I(INS_addiw, EA_8BYTE, tmpRegOp1, regOp1, 0);
}
regOp1 = tmpRegOp1;
break;
}
case EA_8BYTE:
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/emitriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4164,7 +4164,7 @@ regNumber emitter::emitInsTernary(instruction ins, emitAttr attr, GenTree* dst,
}
else
{
emitIns_R_R_R(INS_mulhu, attr, codeGen->rsGetRsvdReg(), src1->GetRegNum(), src2->GetRegNum());
emitIns_R_R_R(INS_mulh, attr, codeGen->rsGetRsvdReg(), src1->GetRegNum(), src2->GetRegNum());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lowerriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ GenTree* Lowering::LowerJTrue(GenTreeOp* jtrue)

if (op->OperIsCompare() && !varTypeIsFloating(op->gtGetOp1()))
{
// We do not expect any other relops on LA64
// We do not expect any other relops on RISCV64
assert(op->OperIs(GT_EQ, GT_NE, GT_LT, GT_LE, GT_GE, GT_GT));

cond = GenCondition::FromRelop(op);
Expand Down

0 comments on commit f026bb0

Please sign in to comment.