Skip to content

Commit 565e6d0

Browse files
authored
Use VN instead of GenTree in optGlobalAssertionIsEqualOrNotEqual (#99182)
1 parent 70bb372 commit 565e6d0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/coreclr/jit/assertionprop.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,20 +4216,20 @@ AssertionIndex Compiler::optGlobalAssertionIsEqualOrNotEqual(ASSERT_VALARG_TP as
42164216
return assertionIndex;
42174217
}
42184218

4219-
// Look for matching exact type assertions based on vtable accesses
4219+
// Look for matching exact type assertions based on vtable accesses. E.g.:
4220+
//
4221+
// op1: VNF_InvariantLoad(myObj) or in other words: a vtable access
4222+
// op2: 'MyType' class handle
4223+
// Assertion: 'myObj's type is exactly MyType
4224+
//
42204225
if ((curAssertion->assertionKind == OAK_EQUAL) && (curAssertion->op1.kind == O1K_EXACT_TYPE) &&
4221-
op1->OperIs(GT_IND))
4226+
(curAssertion->op2.vn == vnStore->VNConservativeNormalValue(op2->gtVNPair)) && op1->TypeIs(TYP_I_IMPL))
42224227
{
4223-
GenTree* indirAddr = op1->AsIndir()->Addr();
4224-
4225-
if (indirAddr->OperIs(GT_LCL_VAR) && (indirAddr->TypeGet() == TYP_REF))
4228+
VNFuncApp funcApp;
4229+
if (vnStore->GetVNFunc(vnStore->VNConservativeNormalValue(op1->gtVNPair), &funcApp) &&
4230+
(funcApp.m_func == VNF_InvariantLoad) && (curAssertion->op1.vn == funcApp.m_args[0]))
42264231
{
4227-
// op1 is accessing vtable of a ref type local var
4228-
if ((curAssertion->op1.vn == vnStore->VNConservativeNormalValue(indirAddr->gtVNPair)) &&
4229-
(curAssertion->op2.vn == vnStore->VNConservativeNormalValue(op2->gtVNPair)))
4230-
{
4231-
return assertionIndex;
4232-
}
4232+
return assertionIndex;
42334233
}
42344234
}
42354235
}

0 commit comments

Comments
 (0)