Skip to content
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