-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Eliminate constant inputs and output constants for simple operations #115506
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
Comments
A little more detail would be helpful. Even just an example. |
Here's the design: At every point where we propagate constants, we also try to eliminate the last int zap_all_constants() {
// zap_all_constants
// We probably don't want to store non-immortal constants, as they complicate reference counting.
if (!_PyObject_IsImmortal(const_val) {
return 0;
}
stack_effect = -stack_inputs(opcode);
_PyUopInstruction *start = curr_instr;
while (op_is_pure(start) && stack_effect > 0) {
stack_effect += net_stack_effect(start);
start--;
}
if (stack_effect != 0) {
return 0;
}
for (; start < curr_instr; start++) {
REPLACE_OP(start, _NOP, 0, 0);
}
return 1;
}
// Do this outside, because some ops have more than one stack output (e.g. a PUSH_NULL):
if (zap_all_constants(...)) {
REPLACE_OP(curr_instr, _LOAD_CONST_INLINE_BORROW, 0, const_val);
} This also means we will never overshoot the buffer, because anything that requires the old |
What would the code in the redundancy elimination pass for |
Can you make seperate issues for |
Linked PRs
The text was updated successfully, but these errors were encountered: