Calling `HasIndex` from `gtIsVtableAccess` can leads to asserts as the
underly code checks to see if the addressing sub-expressions are
contained. But earlyProp runs early enough that it is not concerned with
containment. The code just needs to verify that there is a ref type base
and no index. Rework the code to do the checks directly.
{
if (tree->OperGet() == GT_IND)
{
- GenTreeIndir* indir = tree->AsIndir();
+ GenTree* addr = tree->AsIndir()->Addr();
- if (!indir->HasIndex())
+ if (addr->OperIsAddrMode())
{
- // Check if the base is an reference pointer.
- if (indir->Base()->TypeGet() == TYP_REF)
- {
- return true;
- }
+ GenTreeAddrMode* addrMode = addr->AsAddrMode();
+
+ return (!addrMode->HasIndex() &&
+ (addrMode->Base()->TypeGet() == TYP_REF));
}
}