gh-131798: Small improvements to remove_unneeded_uops#134554
gh-131798: Small improvements to remove_unneeded_uops#134554Fidget-Spinner merged 1 commit intopython:mainfrom
remove_unneeded_uops#134554Conversation
| if (op_without_push[last->opcode]) { | ||
| if (op_without_push[last->opcode] && op_without_pop[opcode]) { | ||
| last->opcode = op_without_push[last->opcode]; | ||
| opcode = buffer[pc].opcode = op_without_pop[opcode]; |
There was a problem hiding this comment.
When we are here, we know that op_without_pop[opcode] || op_without_pop_null[opcode] is true. But we should also make sure that op_without_pop[opcode] itself is true, otherwise it is possible to accidentally write 0 as the opcode.
I read the code but just checking that I understand it right: |
Yes, that's exactly the case! This allows us to optimize for instance: into just |
|
…GH-134554) Improve remove_unneeded_uops
…GH-134554) Improve remove_unneeded_uops
_CHECK_PERIODICto the list of skipped instructions. I believe this is safe to do since this instruction does not modify the stack. It is also relatively common so I think it's worth it to skip it.