Skip to content

Commit ed30a3c

Browse files
authored
gh-114083: apply optimization of LOAD_CONST instructions to the whole CFG before optimize_basic_block. (#114408)
1 parent a53e56e commit ed30a3c

File tree

3 files changed

+191
-143
lines changed

3 files changed

+191
-143
lines changed

Lib/test/test_compile.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,17 @@ def test_condition_expression_with_dead_blocks_compiles(self):
449449
compile('if (5 if 5 else T): 0', '<eval>', 'exec')
450450

451451
def test_condition_expression_with_redundant_comparisons_compiles(self):
452-
# See gh-113054
453-
with self.assertWarns(SyntaxWarning):
454-
compile('if 9<9<9and 9or 9:9', '<eval>', 'exec')
452+
# See gh-113054, gh-114083
453+
exprs = [
454+
'if 9<9<9and 9or 9:9',
455+
'if 9<9<9and 9or 9or 9:9',
456+
'if 9<9<9and 9or 9or 9or 9:9',
457+
'if 9<9<9and 9or 9or 9or 9or 9:9',
458+
]
459+
for expr in exprs:
460+
with self.subTest(expr=expr):
461+
with self.assertWarns(SyntaxWarning):
462+
compile(expr, '<eval>', 'exec')
455463

456464
def test_dead_code_with_except_handler_compiles(self):
457465
compile(textwrap.dedent("""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Compiler applies folding of LOAD_CONST with following instruction in a separate pass before other optimisations. This enables jump threading in certain circumstances.

0 commit comments

Comments
 (0)