Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LoongArch64] Fix the add overflow check for A=A+A. #105674

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/coreclr/jit/emitloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4918,7 +4918,7 @@ regNumber emitter::emitInsTernary(instruction ins, emitAttr attr, GenTree* dst,

if (needCheckOv)
{
emitIns_R_R_R(INS_or, attr, REG_R21, nonIntReg->GetRegNum(), REG_R0);
emitIns_R_R_I(INS_ori, attr, REG_R21, nonIntReg->GetRegNum(), 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? Does it have any difference between OR zr and ORI imm#0?
Which one is used consistently in codegen for LA?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here OR zr and ORI imm#0 do the same thing, but ORI imm#0 is used consistently for $rd=$rn.

}

emitIns_R_R_I(ins, attr, dst->GetRegNum(), nonIntReg->GetRegNum(), imm);
Expand Down Expand Up @@ -5058,7 +5058,18 @@ regNumber emitter::emitInsTernary(instruction ins, emitAttr attr, GenTree* dst,

if (dst->OperIs(GT_ADD))
{
saveOperReg1 = (dst->GetRegNum() == regOp1) ? regOp2 : regOp1;
saveOperReg1 = regOp1;
if (dst->GetRegNum() == regOp1)
{
saveOperReg1 = regOp2;
if (regOp1 == regOp2)
{
assert(REG_R21 != regOp1);
assert(REG_RA != regOp1);
emitIns_R_R_I(INS_ori, attr, REG_R21, regOp1, 0);
saveOperReg1 = REG_R21;
}
}
}
else
{
Expand All @@ -5067,7 +5078,7 @@ regNumber emitter::emitInsTernary(instruction ins, emitAttr attr, GenTree* dst,
assert(REG_R21 != regOp1);
assert(REG_RA != regOp1);
saveOperReg1 = REG_R21;
emitIns_R_R_R(INS_or, attr, REG_R21, regOp1, REG_R0);
emitIns_R_R_I(INS_ori, attr, REG_R21, regOp1, 0);
}
else
{
Expand Down
Loading