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

optRelopImpliesRelop experiments #70616

Closed
wants to merge 6 commits into from
Closed

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jun 11, 2022

Fixes #70373
Might also close #65327 if it works

Minimal repro (the reason why #70373 regressed):

bool Test(int a, int b) => a.CompareTo(b) > 0;

codegen diff: https://www.diffchecker.com/5vriKD2u

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 11, 2022
@ghost ghost assigned EgorBo Jun 11, 2022
@ghost
Copy link

ghost commented Jun 11, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #70373
Might also close #65327 if it works

Minimal repro (the reason why #70373 regressed):

bool Test(int a, int b) => a.CompareTo(b) > 0;

codegen diff: https://www.diffchecker.com/5vriKD2u

image

Diffs were promising but I am not sure it works as expected so waiting for CI

Author: EgorBo
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@EgorBo EgorBo changed the title JIT: "X>=Y" means that "X<=Y" is true, etc JIT: if X >= Y than X <= Y is always true, etc Jun 11, 2022
@EgorBo EgorBo changed the title JIT: if X >= Y than X <= Y is always true, etc JIT: if X >= Y then X <= Y is always true, etc Jun 11, 2022
@AndyAyersMS
Copy link
Member

This is a tricky area.

We might want to invest first in some kind of test case generator, though there's no guarantee C# source predicates will end up inspiring the same kind of IL predicate or that the JIT won't invert the IL predicates somewhere along the line.

You also may (or may not) find table 2 in Mueller and Whalley's Avoiding Conditional Branches by Code Replication useful. (There may be more modern writeups that cover this more broadly; they focus on X RELOP C1 dominating X RELOP C2).

@EgorBo EgorBo changed the title JIT: if X >= Y then X <= Y is always true, etc optRelopImpliesRelop experiments Jun 11, 2022
@EgorBo
Copy link
Member Author

EgorBo commented Jun 12, 2022

Right, I'll read the paper and experiment locally

@EgorBo EgorBo closed this Jun 12, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 12, 2022
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.

Perf regressions in sorting JIT doesn't eliminate redundant branch in guarded span.Slice
2 participants