@@ -611,43 +611,32 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
611611 // _LOAD_FAST + _POP_TWO_LOAD_CONST_INLINE_BORROW + _POP_TOP
612612 // ...becomes:
613613 // _NOP + _POP_TOP + _NOP
614- again :
615- while (op_without_pop [opcode ]) {
614+ while (op_without_pop [opcode ] || opcode == _POP_CALL || opcode == _POP_CALL_LOAD_CONST_INLINE_BORROW ) {
616615 _PyUOpInstruction * last = & buffer [pc - 1 ];
617616 while (op_skip [last -> opcode ]) {
618617 last -- ;
619618 }
620- if (!op_without_push [last -> opcode ]) {
621- break ;
622- }
623- last -> opcode = op_without_push [last -> opcode ];
624- opcode = buffer [pc ].opcode = op_without_pop [opcode ];
625- if (op_without_pop [last -> opcode ]) {
626- opcode = last -> opcode ;
627- pc = last - buffer ;
628- }
629- }
630- // Handle _POP_CALL and _POP_CALL_LOAD_CONST_INLINE_BORROW separately.
631- // This looks for a preceding _PUSH_NULL instruction and simplifies to _POP_TOP.
632- if (opcode == _POP_CALL || opcode == _POP_CALL_LOAD_CONST_INLINE_BORROW ) {
633- _PyUOpInstruction * last = & buffer [pc - 1 ];
634- while (op_skip [last -> opcode ]) {
635- last -- ;
619+ if (op_without_push [last -> opcode ]) {
620+ last -> opcode = op_without_push [last -> opcode ];
621+ opcode = buffer [pc ].opcode = op_without_pop [opcode ];
622+ if (op_without_pop [last -> opcode ]) {
623+ opcode = last -> opcode ;
624+ pc = last - buffer ;
625+ }
636626 }
637- if (last -> opcode == _PUSH_NULL ) {
627+ else if (last -> opcode == _PUSH_NULL ) {
628+ // Handle _POP_CALL and _POP_CALL_LOAD_CONST_INLINE_BORROW separately.
629+ // This looks for a preceding _PUSH_NULL instruction and
630+ // simplifies to _POP_TOP(_LOAD_CONST_INLINE_BORROW).
638631 last -> opcode = _NOP ;
639632 if (opcode == _POP_CALL ) {
640633 opcode = buffer [pc ].opcode = _POP_TOP ;
641634 }
642635 else {
643636 opcode = buffer [pc ].opcode = _POP_TOP_LOAD_CONST_INLINE_BORROW ;
644637 }
645- opcode = buffer [pc ].opcode = _POP_TOP ;
646- if (op_without_pop [last -> opcode ]) {
647- opcode = last -> opcode ;
648- pc = last - buffer ;
649- }
650- goto again ;
638+ } else {
639+ break ;
651640 }
652641 }
653642 /* _PUSH_FRAME doesn't escape or error, but it
0 commit comments