Skip to content

Commit

Permalink
JIT: filter local assertion set (#110091)
Browse files Browse the repository at this point in the history
During `optAssertionProp_Lcl{Fld,Var}`, only consider assertions involving the local var.
  • Loading branch information
AndyAyersMS authored Nov 23, 2024
1 parent 35e23f7 commit f1332ab
Showing 1 changed file with 16 additions and 3 deletions.
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

0 comments on commit f1332ab

Please sign in to comment.