-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: better optimization for CORINFO_HELP_RUNTIMEHANDLE_METHOD #7590
Comments
Keep in 2.0 for Span on Kestrel. |
We already recognize this helper of pure, and our definition of "pure" already requires that the helper's behavior not depend on mutable heap state, so we can already CSE such calls. The cases showing up in the SpanBench benchmark aren't getting CSE'd because each is conditionally executed (so the 1st occurrence isn't available at the 2nd one on the path that branched around it). That said, perhaps we should be able to recognize the conditions guarding them as equivalent? The test does a two-level indirection off
and here's where we value-number the second:
We recognize that (even if we did recognize the tests as redundant, though, we currently don't track gating predicates when value-numbering phis, and so wouldn't recognize the second sequence as redundant without addressing that) |
@JosephTremoulet, any updates on this issue? |
Not yet; still need to track down what that context/dictionary lookup sequence is loading and whether we can assume it is immutable to know if this is possible. Assuming it is, doing a full-blown control dependence analysis for tracking phi gating predicates is likely out-of-scope for a while, but we might be able to get some mileage out of recognizing cases where the flow graph has a simple single-conditional-block "if" or two-conditional-block "if/else" pattern and number phis like questions in those join blocks. |
After discussion with @JosephTremoulet swapping this for the span bounds check work in #7589. |
It turns out the indirection in question is one that we generate when the JIT calls The comment for
It's not clear to me from either of those if we can/should assume that the dereference we generate to implement the I'm not familiar enough with the runtime side to know the answer. @jkotas? |
This is the correct assumption to make. The indirection is lazily initialized. If it is non-null, you have the good value. If it is null, the helper will initialize so that it is non-null next time. |
So then the importer is correct to not flag the load as invariant. The whole load-test-init sequence is CSEable, but trying to mark all the individual pieces as such would lead to redundant calls to the initialization helper. It may be worth considering delaying the expansion of the lookup sequence so that we could value-number it as a whole before exposing the parts... |
Another approach would be to track assertions of the form " |
@JosephTremoulet, any updates on this issue? |
I suppose @AndyAyersMS or @RussKeldorph would be in the best position to answer that. |
We are not going to get to this in 2.1 so we should update #6168 to reflect this. |
I updated the original post of https://github.com/dotnet/coreclr/issues/5851. Thanks |
This helper depends on the (exact) type of the object passed to it, not the contents/fields of that objects. Since an object's type is initialized anywhere the object pointer is available and is immutable for the lifetime of the object, we should therefore be able to give this helper call a value number that is a function of the pointer argument, rather than the memory the argument points to, and eliminate redundant calls such as we see in shared generic code.
category:cq
theme:helpers
skill-level:expert
cost:medium
The text was updated successfully, but these errors were encountered: