Skip to content
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

Eliminate dead branches around typeof comparisons #102248

Merged
merged 4 commits into from
Jun 19, 2024

Commits on May 15, 2024

  1. Eliminate dead branches around typeof comparisons

    RyuJIT will already do dead branch elimination for `typeof(X) == typeof(Y)` patterns, but we couldn't do elimination around `foo == typeof(X)`. This fixes that using whole program knowledge - if we never saw a constructed `MT` for `X`, the comparison is not going to be true. Because it needs whole program, we still scan this dead branch so in the end this doesn't save much. We can eventually do better.
    
    I'm doing this in `SubstitutedILProvider` instead of in RyuJIT: this is because we currently only reap a small benefit from this optimization due to it only happening during compilation phase. We need to do this during scanning as well. I think I can extend it to scannig. But the extension will require the optimization to 100% guaranteed happen during codegen. We cannot rely on whether RyuJIT will feel like it. `SubstitutedILProvider` is our way to ensure the optimization will happen no matter what - the IL from the branch will be gone and RyuJIT can at most remove the comparison (we don't mind much if it's left).
    MichalStrehovsky committed May 15, 2024
    Configuration menu
    Copy the full SHA
    a2ccfc8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6beca33 View commit details
    Browse the repository at this point in the history

Commits on May 20, 2024

  1. Fixes

    MichalStrehovsky committed May 20, 2024
    Configuration menu
    Copy the full SHA
    31c52b0 View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2024

  1. Configuration menu
    Copy the full SHA
    ea42b25 View commit details
    Browse the repository at this point in the history