-
-
Couldn't load subscription status.
- Fork 3k
[mypyc] feat: add rare kwarg to IRBuilder.add_bool_branch
#20099
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
base: master
Are you sure you want to change the base?
Conversation
|
I imagine it would be nicer if we bundled a change like this with optimization (mark branches with pragmas). Otherwise I feel like complexity doesn't automatically help! Also that would let the actual perf impacts be looked at (branch misprediction counts?). |
|
Well, it exists for this one case so it seems someone else decided this case was worthy enough to write a bunch of code for. I'm not the one who wrote that optimization, I'm just writing a tiny bit more code so other parts of the codebase can reuse it |
|
Ah I see, I missed that. |
|
@A5rocks originally I was trying to figure out how to use this I failed at that for the time being but that can still come down the pipe after this once I have more time to experiment with it |
| builder.read(instance), builder.none_object(), "is", line | ||
| ) | ||
| builder.add_bool_branch(comparison, class_block, instance_block) | ||
| builder.add_bool_branch(comparison, class_block, instance_block, rare=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one might be questionable
This doesn't do much, currently it enables just one optimization which already exists in the codebase: it helps mypyc determine whether to use CPyTagged_XDECREF or CPyTagged_XDecRef within a particular block
But it's semantically reasonable to accept a rare flag for any boolean branch, even if it doesn't do too much optimizing, and it opens the door for us to implement further optimizations in this area