diff options
Diffstat (limited to 'Python/flowgraph.c')
-rw-r--r-- | Python/flowgraph.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 2fd9a85b6d9..b16b508fe76 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -1515,15 +1515,18 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts) */ } break; + case STORE_FAST: + if (opcode == nextop && + oparg == bb->b_instr[i+1].i_oparg && + bb->b_instr[i].i_loc.lineno == bb->b_instr[i+1].i_loc.lineno) { + bb->b_instr[i].i_opcode = POP_TOP; + bb->b_instr[i].i_oparg = 0; + } + break; case SWAP: if (oparg == 1) { INSTR_SET_OP0(inst, NOP); - break; - } - if (swaptimize(bb, &i) < 0) { - goto error; } - apply_static_swaps(bb, i); break; case KW_NAMES: break; @@ -1538,6 +1541,16 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts) assert (!HAS_CONST(inst->i_opcode)); } } + + for (int i = 0; i < bb->b_iused; i++) { + cfg_instr *inst = &bb->b_instr[i]; + if (inst->i_opcode == SWAP) { + if (swaptimize(bb, &i) < 0) { + goto error; + } + apply_static_swaps(bb, i); + } + } return SUCCESS; error: return ERROR; |