Skip to content

Commit 892b44c

Browse files
committed
Remove some redundant CHECK_PERIODICs
1 parent 494c825 commit 892b44c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Python/flowgraph.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,6 +2290,7 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
22902290
assert(PyList_CheckExact(consts));
22912291
cfg_instr nop;
22922292
INSTR_SET_OP0(&nop, NOP);
2293+
bool seen_check = false;
22932294
for (int i = 0; i < bb->b_iused; i++) {
22942295
cfg_instr *inst = &bb->b_instr[i];
22952296
cfg_instr *target;
@@ -2481,6 +2482,17 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
24812482
case BINARY_OP:
24822483
RETURN_IF_ERROR(fold_const_binop(bb, i, consts, const_cache));
24832484
break;
2485+
case CALL:
2486+
case CALL_KW:
2487+
case CALL_FUNCTION_EX:
2488+
seen_check = false;
2489+
break;
2490+
case CHECK_PERIODIC:
2491+
if (seen_check) {
2492+
INSTR_SET_OP0(inst, NOP);
2493+
}
2494+
seen_check = true;
2495+
break;
24842496
}
24852497
}
24862498

0 commit comments

Comments
 (0)