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

fix the regs conflicts within the addResolution for LoongArch64 and RISC-V. #86294

Merged
merged 3 commits into from
May 17, 2023
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
32 changes: 24 additions & 8 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8102,7 +8102,8 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
}
}

LclVarDsc* terminatorNodeLclVarDsc = nullptr;
LclVarDsc* terminatorNodeLclVarDsc = nullptr;
LclVarDsc* terminatorNodeLclVarDsc2 = nullptr;
// Next, if this blocks ends with a switch table, or for Arm64, ends with JCMP/JTEST instruction,
// make sure to not copy into the registers that are consumed at the end of this block.
//
Expand Down Expand Up @@ -8162,18 +8163,28 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
GenTree* srcOp = op->gtGetOp1();
consumedRegs |= genRegMask(srcOp->GetRegNum());
}

if (op->IsLocal())
else if (op->IsLocal())
{
GenTreeLclVarCommon* lcl = op->AsLclVarCommon();
terminatorNodeLclVarDsc = &compiler->lvaTable[lcl->GetLclNum()];
}

#if !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64)
// TODO-LOONGARCH64: Take into account that on LA64, the second
// operand of a JCMP can be in a register too.
assert(!lastNode->OperIs(GT_JCMP, GT_JTEST) || lastNode->gtGetOp2()->isContained());
#endif
if (lastNode->OperIs(GT_JCMP, GT_JTEST) && !lastNode->gtGetOp2()->isContained())
{
op = lastNode->gtGetOp2();
consumedRegs |= genRegMask(op->GetRegNum());

if (op->OperIs(GT_COPY))
{
GenTree* srcOp = op->gtGetOp1();
consumedRegs |= genRegMask(srcOp->GetRegNum());
}
else if (op->IsLocal())
{
GenTreeLclVarCommon* lcl = op->AsLclVarCommon();
terminatorNodeLclVarDsc2 = &compiler->lvaTable[lcl->GetLclNum()];
}
}
}
}

Expand Down Expand Up @@ -8257,6 +8268,11 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
{
sameToReg = REG_NA;
}
else if ((terminatorNodeLclVarDsc2 != nullptr) &&
(terminatorNodeLclVarDsc2->lvVarIndex == outResolutionSetVarIndex))
{
sameToReg = REG_NA;
}
#endif // defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)

// If the var is live only at those blocks connected by a split edge and not live-in at some of the
Expand Down