Skip to content

Commit

Permalink
Fixing where ClearContained is called for certain Arm64 cast ops
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Oct 2, 2022
1 parent 144a33a commit 6e147d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
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 @@ -2010,13 +2007,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

0 comments on commit 6e147d3

Please # to comment.