Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 14 additions & 3 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4589,7 +4589,7 @@ GenTree* Compiler::optAssertionProp_Comma(ASSERT_VALARG_TP assertions, GenTree*
//
GenTree* Compiler::optAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* tree, Statement* stmt)
{
assert(tree->OperIsIndir());
assert(tree->OperIsIndirOrArrMetaData());

bool updated = optNonNullAssertionProp_Ind(assertions, tree);
if (tree->OperIs(GT_STOREIND))
Expand Down Expand Up @@ -4776,14 +4776,14 @@ GenTree* Compiler::optNonNullAssertionProp_Call(ASSERT_VALARG_TP assertions, Gen
//
bool Compiler::optNonNullAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree* indir)
{
assert(indir->OperIsIndir());
assert(indir->OperIsIndirOrArrMetaData());

if ((indir->gtFlags & GTF_EXCEPT) == 0)
{
return false;
}

if (optAssertionIsNonNull(indir->AsIndir()->Addr(), assertions))
if (optAssertionIsNonNull(indir->GetIndirOrArrMetaDataAddr(), assertions))
{
JITDUMP("Non-null assertion prop for indirection [%06d] in " FMT_BB ":\n", dspTreeID(indir), compCurBB->bbNum);

Expand Down Expand Up @@ -5296,6 +5296,17 @@ GenTree* Compiler::optAssertionProp(ASSERT_VALARG_TP assertions, GenTree* tree,
case GT_UDIV:
return optAssertionProp_ModDiv(assertions, tree->AsOp(), stmt, block);

case GT_ARR_LENGTH:
// Unfortunately, doing this in LocalAP produces an asymmetry in exception sets between
// uses/defs that CSE does not manage to make good use of. As a result, some bounds checks are no longer
// removed.
// TODO-CSE: Allow CSE'ing uses with defs if the defs promise a superset of exceptions
if (!optLocalAssertionProp)
{
return optAssertionProp_Ind(assertions, tree, stmt);
}
return nullptr;

case GT_BLK:
case GT_IND:
case GT_STOREIND:
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7554,6 +7554,9 @@ bool GenTree::OperSupportsOrderingSideEffect() const

switch (OperGet())
{
case GT_ARR_LENGTH:
case GT_MDARR_LENGTH:
case GT_MDARR_LOWER_BOUND:
case GT_ARR_ADDR:
case GT_BOUNDS_CHECK:
case GT_IND:
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/optimizebools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,7 @@ void OptBoolsDsc::optOptimizeBoolsUpdateTrees()
{
m_compiler->gtSetStmtInfo(m_testInfo1.testStmt);
m_compiler->fgSetStmtSeq(m_testInfo1.testStmt);
m_compiler->gtUpdateStmtSideEffects(m_testInfo1.testStmt);
}

/* Modify the target of the conditional jump and update bbRefs and bbPreds */
Expand Down
Loading