diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-07-01 11:28:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-01 11:28:07 +0100 |
commit | 200f2554114f3d40684af0969fef6af875cb1462 (patch) | |
tree | d2b3a575b3d3397430ccd1d81e49afd78aefaa0a /Python/flowgraph.c | |
parent | d3abc9b5165eee7dbe24f8f081c0739e6ad3ef3b (diff) | |
download | cpython-200f2554114f3d40684af0969fef6af875cb1462.tar.gz cpython-200f2554114f3d40684af0969fef6af875cb1462.zip |
gh-106149: move unconditional jump direction resolution from optimizer to assembler (#106291)
Diffstat (limited to 'Python/flowgraph.c')
-rw-r--r-- | Python/flowgraph.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/Python/flowgraph.c b/Python/flowgraph.c index 429109b74be..213c993bb86 100644 --- a/Python/flowgraph.c +++ b/Python/flowgraph.c @@ -393,24 +393,17 @@ no_redundant_jumps(cfg_builder *g) { static int normalize_jumps_in_block(cfg_builder *g, basicblock *b) { cfg_instr *last = _PyCfg_BasicblockLastInstr(b); - if (last == NULL || !is_jump(last)) { + if (last == NULL || !is_jump(last) || + IS_UNCONDITIONAL_JUMP_OPCODE(last->i_opcode)) { return SUCCESS; } assert(!IS_ASSEMBLER_OPCODE(last->i_opcode)); + bool is_forward = last->i_target->b_visited == 0; - switch(last->i_opcode) { - case JUMP: - assert(SAME_OPCODE_METADATA(JUMP, JUMP_FORWARD)); - assert(SAME_OPCODE_METADATA(JUMP, JUMP_BACKWARD)); - last->i_opcode = is_forward ? JUMP_FORWARD : JUMP_BACKWARD; - return SUCCESS; - case JUMP_NO_INTERRUPT: - assert(SAME_OPCODE_METADATA(JUMP_NO_INTERRUPT, JUMP_FORWARD)); - assert(SAME_OPCODE_METADATA(JUMP_NO_INTERRUPT, JUMP_BACKWARD_NO_INTERRUPT)); - last->i_opcode = is_forward ? - JUMP_FORWARD : JUMP_BACKWARD_NO_INTERRUPT; - return SUCCESS; + if (is_forward) { + return SUCCESS; } + int reversed_opcode = 0; switch(last->i_opcode) { case POP_JUMP_IF_NOT_NONE: @@ -426,9 +419,6 @@ normalize_jumps_in_block(cfg_builder *g, basicblock *b) { reversed_opcode = POP_JUMP_IF_FALSE; break; } - if (is_forward) { - return SUCCESS; - } /* transform 'conditional jump T' to * 'reversed_jump b_next' followed by 'jump_backwards T' */ |