gh-93678: apply remove_redundant_jumps in optimize_cfg (GH-96274)

This commit is contained in:
Irit Katriel 2022-09-01 11:03:52 +01:00 committed by GitHub
parent e93d1bda77
commit 894cafd9a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 14 deletions

View file

@ -892,7 +892,8 @@ class DirectiCfgOptimizerTests(CfgOptimizationTestCase):
self.cfg_optimization_test(insts, expected, consts=list(range(5)))
def test_conditional_jump_forward_const_condition(self):
# The unreachable branch of the jump is removed
# The unreachable branch of the jump is removed, the jump
# becomes redundant and is replaced by a NOP (for the lineno)
insts = [
('LOAD_CONST', 3, 11),
@ -903,8 +904,7 @@ class DirectiCfgOptimizerTests(CfgOptimizationTestCase):
]
expected = [
('NOP', None, 11),
('JUMP', lbl := self.Label(), 12),
lbl,
('NOP', None, 12),
('LOAD_CONST', '3', 14)
]
self.cfg_optimization_test(insts, expected, consts=list(range(5)))