Skip to content
Closed
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
9 changes: 6 additions & 3 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4454,7 +4454,7 @@ 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))
{
Expand All @@ -4465,7 +4465,7 @@ bool Compiler::optNonNullAssertionProp_Ind(ASSERT_VALARG_TP assertions, GenTree*
bool vnBased = false;
AssertionIndex index = NO_ASSERTION_INDEX;
#endif
if (optAssertionIsNonNull(indir->AsIndir()->Addr(), assertions DEBUGARG(&vnBased) DEBUGARG(&index)))
if (optAssertionIsNonNull(indir->GetIndirOrArrMetaDataAddr(), assertions DEBUGARG(&vnBased) DEBUGARG(&index)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will note a subtle property of this code: it is relying on array metadata only being used for arrays (TYP_REF, aka heap objects). Array metadata indirections contain an implicit offset addition before the dereference - if array metadata nodes were more "general-purpose" (applicable to random pointers), the code would needs to be made aware of it. However, TYP_REF is either null or a valid object, so this is not necessary.

{
#ifdef DEBUG
if (verbose)
Expand Down Expand Up @@ -4792,6 +4792,9 @@ GenTree* Compiler::optAssertionProp(ASSERT_VALARG_TP assertions, GenTree* tree,
case GT_STOREIND:
case GT_NULLCHECK:
case GT_STORE_DYN_BLK:
case GT_ARR_LENGTH:
case GT_MDARR_LENGTH:
case GT_MDARR_LOWER_BOUND:
return optAssertionProp_Ind(assertions, tree, stmt);

case GT_BOUNDS_CHECK:
Expand Down Expand Up @@ -5858,7 +5861,7 @@ void Compiler::optVnNonNullPropCurStmt(BasicBlock* block, Statement* stmt, GenTr
{
newTree = optNonNullAssertionProp_Call(empty, tree->AsCall());
}
else if (tree->OperIsIndir())
else if (tree->OperIsIndirOrArrMetaData())
{
newTree = optAssertionProp_Ind(empty, tree, stmt);
}
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 @@ -7148,6 +7148,9 @@ bool GenTree::OperSupportsOrderingSideEffect() const
case GT_CMPXCHG:
case GT_MEMORYBARRIER:
case GT_CATCH_ARG:
case GT_ARR_LENGTH:
case GT_MDARR_LENGTH:
case GT_MDARR_LOWER_BOUND:
return true;
default:
return false;
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 @@ -834,6 +834,7 @@ void OptBoolsDsc::optOptimizeBoolsUpdateTrees()
m_comp->gtSetStmtInfo(m_testInfo1.testStmt);
m_comp->fgSetStmtSeq(m_testInfo1.testStmt);
}
m_comp->gtUpdateStmtSideEffects(m_testInfo1.testStmt);

if (!optReturnBlock)
{
Expand Down