-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
GH-138245: Perform boolean guards by testing a single bit, rather than a full pointer comparison. #143810
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: main
Are you sure you want to change the base?
Conversation
…inter comparison.
| d = id(True) ^ id(False) | ||
| bit = 0 | ||
| for i in range(4, 8): | ||
| if d & (1 << i): | ||
| bit = i | ||
| break | ||
| if bit == 0: | ||
| return "_GUARD_IS_FALSE_POP", "_GUARD_IS_TRUE_POP" | ||
| if id(True) & (1 << bit): | ||
| return f"_GUARD_BIT_IS_UNSET_POP_{bit}", f"_GUARD_BIT_IS_SET_POP_{bit}" | ||
| else: | ||
| return f"_GUARD_BIT_IS_SET_POP_{bit}", f"_GUARD_BIT_IS_UNSET_POP_{bit}" |
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 needs to be dedented one.
| int bit = get_test_bit_for_bools(); | ||
| if (bit) { | ||
| REPLACE_OP(this_instr, | ||
| test_bit_set_in_true(bit) ? |
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.
Please check this once at the context initialization and set it in the context, then fetch the corresponding op to use from the context.
| int bit = get_test_bit_for_bools(); | ||
| if (bit) { | ||
| REPLACE_OP(this_instr, | ||
| test_bit_set_in_true(bit) ? |
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.
Same here.
This reduces the overhead of performing boolean guards in jitted code.
On Aarch64 reduces the size of the stencil from 5 to 2 instructions.
GUARD_IS_FALSE_POP_r10:_GUARD_BIT_IS_SET_POP_4_r10: