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

[mypyc] Generate faster code for bool comparisons and arithmetic #14489

Merged
merged 13 commits into from
Feb 5, 2023

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Jan 21, 2023

Generate specialized, efficient IR for various operations on bools. These are covered:

  • Bool comparisons
  • Mixed bool/integer comparisons
  • Bool arithmetic (binary and unary)
  • Mixed bool/integer arithmetic and bitwise ops

Mixed operations where the left operand is a bool and the right operand is a native int still have some unnecessary conversions between native int and int. This would be a bit trickier to fix and is seems rare, so it doesn't seem urgent to fix this.

Fixes mypyc/mypyc#968.

Some are still poorly supported, since we'd probably need some heavier
weight infrastructure to optimize them. In particular, mixed operations
with bool left operands involve unnecessary conversions to/from int.
A potential way to fix them would be to remove redundant conversions
in an optimization pass, but right now that would be messy to implement.
@JukkaL JukkaL merged commit 5614ffa into master Feb 5, 2023
@JukkaL JukkaL deleted the mypyc-bool2 branch February 5, 2023 11:57
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.

Speed up bool comparison and arithmetic operations
2 participants