Skip to content
New issue

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

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

Already on GitHub? # to your account

Fixing where ClearContained is called for certain Arm64 cast ops #76517

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2816,23 +2816,22 @@ GenTree* Lowering::OptimizeConstCompare(GenTree* cmp)
op2->gtType = castToType;
#endif
// If we have any contained memory ops on castOp, they must now not be contained.
castOp->ClearContained();

if (castOp->OperIs(GT_OR, GT_XOR, GT_AND))
{
GenTree* op1 = castOp->gtGetOp1();
if ((op1 != nullptr) && !op1->IsCnsIntOrI())
{
op1->ClearContained();
}

GenTree* op2 = castOp->gtGetOp2();
if ((op2 != nullptr) && !op2->IsCnsIntOrI())
{
op2->ClearContained();
}
}
else
{
castOp->ClearContained();
}

cmp->AsOp()->gtOp1 = castOp;

Expand Down
15 changes: 12 additions & 3 deletions src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ bool Lowering::IsContainableBinaryOp(GenTree* parentNode, GenTree* childNode) co
// Find "a op cast(b)"
GenTree* castOp = childNode->AsCast()->CastOp();

// We want to prefer the combined op here over containment of the cast op
castOp->ClearContained();

bool isSupportedCast = false;

if (varTypeIsSmall(childNode->CastToType()))
Expand Down Expand Up @@ -2015,13 +2012,25 @@ void Lowering::ContainCheckBinary(GenTreeOp* node)
{
if (IsContainableBinaryOp(node, op2))
{
if (op2->OperIs(GT_CAST))
{
// We want to prefer the combined op here over containment of the cast op
op2->AsCast()->CastOp()->ClearContained();
}
MakeSrcContained(node, op2);

return;
}

if (node->OperIsCommutative() && IsContainableBinaryOp(node, op1))
{
if (op1->OperIs(GT_CAST))
{
// We want to prefer the combined op here over containment of the cast op
op1->AsCast()->CastOp()->ClearContained();
}
MakeSrcContained(node, op1);

std::swap(node->gtOp1, node->gtOp2);
return;
}
Expand Down