Skip to content

[mypyc] Simplify IR for tagged integer comparisons #9607

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

Merged
merged 8 commits into from
Oct 18, 2020
Merged

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Oct 17, 2020

In a conditional context, such as in an if condition, simplify the
IR for tagged integer comparisons. Also perform some additional
optimizations if an operand is known to be a short integer.

This slightly improves performance when compiling with no
optimizations. The impact should be pretty negligible otherwise.

This is a bit simple-minded, and some further optimizations are
possible. For example, 3 < x < 6 could be made faster. This
covers the most common cases, however.

Closes mypyc/mypyc#758.

This reduces the number of ops and registers typically by two. This
also makes it easier to generate good code in a custom backend.
We could also do this for lhs, but it's less common.
Copy link
Collaborator

@TH3CHARLie TH3CHARLie left a comment

Choose a reason for hiding this comment

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

LGTM! Just need to fix the native_int IR issue that is currently failing on 32bit platforms.

@JukkaL JukkaL merged commit 27a9830 into master Oct 18, 2020
@JukkaL JukkaL deleted the mypyc-compare branch October 18, 2020 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify IR for comparisons
2 participants