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

JIT: filter local assertion set #110091

Merged
merged 1 commit into from
Nov 23, 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
19 changes: 16 additions & 3 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3623,7 +3623,17 @@ GenTree* Compiler::optAssertionProp_LclVar(ASSERT_VALARG_TP assertions, GenTreeL
return nullptr;
}

BitVecOps::Iter iter(apTraits, assertions);
// For local assertion prop we can filter the assertion set down.
//
const unsigned lclNum = tree->GetLclNum();

ASSERT_TP filteredAssertions = assertions;
if (optLocalAssertionProp)
{
filteredAssertions = BitVecOps::Intersection(apTraits, GetAssertionDep(lclNum), filteredAssertions);
}

BitVecOps::Iter iter(apTraits, filteredAssertions);
unsigned index = 0;
while (iter.NextElem(&index))
{
Expand Down Expand Up @@ -3672,7 +3682,7 @@ GenTree* Compiler::optAssertionProp_LclVar(ASSERT_VALARG_TP assertions, GenTreeL
// gtFoldExpr, specifically the case of a cast, where the fold operation changes the type of the LclVar
// node. In such a case is not safe to perform the substitution since later on the JIT will assert mismatching
// types between trees.
const unsigned lclNum = tree->GetLclNum();
//
if (curAssertion->op1.lcl.lclNum == lclNum)
{
LclVarDsc* const lclDsc = lvaGetDesc(lclNum);
Expand Down Expand Up @@ -3729,7 +3739,10 @@ GenTree* Compiler::optAssertionProp_LclFld(ASSERT_VALARG_TP assertions, GenTreeL
return nullptr;
}

BitVecOps::Iter iter(apTraits, assertions);
const unsigned lclNum = tree->GetLclNum();
ASSERT_TP filteredAssertions = BitVecOps::Intersection(apTraits, GetAssertionDep(lclNum), assertions);

BitVecOps::Iter iter(apTraits, filteredAssertions);
unsigned index = 0;
while (iter.NextElem(&index))
{
Expand Down
Loading