Skip to content

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

Merged
JukkaL merged 13 commits intomasterfrom
mypyc-bool2
Feb 5, 2023
Merged

[mypyc] Generate faster code for bool comparisons and arithmetic#14489
JukkaL merged 13 commits intomasterfrom
mypyc-bool2

Conversation

@JukkaL
Copy link
Copy Markdown
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.

JukkaL added 12 commits January 13, 2023 19:45
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