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

Optimize JTRUE(cast_helper EQ/NE null) expansion #110272

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
fix bug
  • Loading branch information
EgorBo committed Nov 30, 2024
commit d4b269d33cffdbb6986bcf901855c3671c34245f
11 changes: 9 additions & 2 deletions src/coreclr/jit/helperexpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2392,8 +2392,15 @@ bool Compiler::fgLateCastExpansionForCall(BasicBlock** pBlock, Statement* stmt,
GenTree* cmp = rootNode->gtGetOp1();
if ((cmp->gtGetOp1() == call) && cmp->gtGetOp2()->IsIntegralConst(0))
{
castSucceedsFinalBb = cmp->OperIs(GT_EQ) ? block->GetFalseTarget() : block->GetTrueTarget();
castFailsFinalBb = cmp->OperIs(GT_EQ) ? block->GetTrueTarget() : block->GetFalseTarget();
castSucceedsFinalBb = block->GetTrueTarget();
castFailsFinalBb = block->GetFalseTarget();

// Assume we deal with "helper != null" pattern by default, we'll swap the targets
// if it's actually "helper == null" or if we're going to return null on success.
if (cmp->OperIs(GT_EQ) != (typeCheckPassedAction == TypeCheckPassedAction::ReturnNull))
{
std::swap(castSucceedsFinalBb, castFailsFinalBb);
}
}
}
}
Expand Down
Loading