Skip to content

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Oct 1, 2024

Closes #104489

Diffs

The main idea to walk Phi nodes in bool ValueNumStore::IsKnownNonNull(ValueNum vn) so if all phi nodes are not-null, then the phi itself is not null as well. Same for "does need a write barrier" detection.

The rest of the changes are unrelated, but they were needed to mitigate TP regression

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 1, 2024
@EgorBo EgorBo marked this pull request as ready for review October 2, 2024 01:09
{
return optCreateAssertion(tree->AsOp()->gtOp1, nullptr, OAK_NOT_EQUAL);
}
return NO_ASSERTION_INDEX;
Copy link
Member Author

Choose a reason for hiding this comment

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

No diff change. Also, it effectively repeats IsKnownNonNull now which also walks phis.

{
break;
}
FALLTHROUGH;
Copy link
Member Author

Choose a reason for hiding this comment

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

Dynamic blocks are no more. No diffs change.

optImpliedByCopyAssertion(iterAssertion, curAssertion, activeAssertions);
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

No diffs change

Copy link
Member

Choose a reason for hiding this comment

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

Seems a little odd that this has no impact... are we not properly maintaining the vn->assertion maps?

Copy link
Member Author

Choose a reason for hiding this comment

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

@AndyAyersMS we do maintain it, but it seems that we never arrive here:

BitVecOps::AddElemD(apTraits, result, impIndex - 1);
(usable is always false, also only O2K_LCLVAR_COPY is visitted)

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I don't understand this aspect of AP very well, so perhaps nothing is wrong, but it still feels like at some point either something broke and we didn't realize, or something rendered all this logic irrelevant (in which case perhaps we can save TP by removing more code elsewhere). Maybe open an issue to investigate?

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #108504

@EgorBo
Copy link
Member Author

EgorBo commented Oct 2, 2024

@AndyAyersMS @dotnet/jit-contrib PTAL

@EgorBo EgorBo requested a review from AndyAyersMS October 2, 2024 01:13

// Helper function for VNVisitReachingVNs
template <typename TArgVisitor>
VNVisit VNVisitReachingVNsWorker(ValueNum vn, TArgVisitor argVisitor)
Copy link
Member Author

@EgorBo EgorBo Oct 2, 2024

Choose a reason for hiding this comment

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

Here I split VNVisitReachingVNs into two functions. In most cases the input is not a phi so we run argVisitor just once - it helps us to avoid creating an on-stack array in VNVisitReachingVNsWorker

Improved JIT TP.

return ValueNumStore::VNVisit::Abort;
};

if (vnStore->VNVisitReachingVNs(value->gtVNPair.GetConservative(), vnVisitor) == ValueNumStore::VNVisit::Continue)
Copy link
Member Author

Choose a reason for hiding this comment

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

Basically, if we have IND(addr) = value where value is either null or an nongc object - we don't need a write-barrier (taking Phi defs into account now).

Similarly, we can walk phis for addr itelf but that didn't show any diffs.

optImpliedByCopyAssertion(iterAssertion, curAssertion, activeAssertions);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Seems a little odd that this has no impact... are we not properly maintaining the vn->assertion maps?

return false;
}

bool ValueNumStore::IsPhiDef(ValueNum vn) const
Copy link
Member

Choose a reason for hiding this comment

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

Header comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

@EgorBo EgorBo merged commit b9ffdb0 into dotnet:main Oct 3, 2024
@EgorBo EgorBo deleted the use-VNVisitReachingVNs-more branch October 3, 2024 18:47
lambdageek pushed a commit to lambdageek/runtime that referenced this pull request Oct 3, 2024
sirntar pushed a commit to sirntar/runtime that referenced this pull request Oct 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: nullcheck is not folded for PHI

2 participants