summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dis.py5
-rw-r--r--Lib/test/test_peepholer.py36
2 files changed, 37 insertions, 4 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 28da3fd..cb35175d 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -808,8 +808,9 @@ dis_extended_arg_quick_code = """\
%3d 2 LOAD_CONST 1 (Ellipsis)
4 EXTENDED_ARG 1
6 UNPACK_EX 256
- 8 STORE_FAST_STORE_FAST 0 (_, _)
- 10 RETURN_CONST 0 (None)
+ 8 POP_TOP
+ 10 STORE_FAST 0 (_)
+ 12 RETURN_CONST 0 (None)
"""% (extended_arg_quick.__code__.co_firstlineno,
extended_arg_quick.__code__.co_firstlineno + 1,)
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index c57016b..82b0b50 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -1077,13 +1077,45 @@ class DirectCfgOptimizerTests(CfgOptimizationTestCase):
expected_insts = [
('LOAD_CONST', 0, 1),
('LOAD_CONST', 1, 2),
+ ('NOP', 0, 3),
+ ('STORE_FAST', 1, 4),
+ ('POP_TOP', 0, 4),
+ ('RETURN_VALUE', 5)
+ ]
+ self.cfg_optimization_test(insts, expected_insts, consts=list(range(3)), nlocals=1)
+
+ def test_dead_store_elimination_in_same_lineno(self):
+ insts = [
+ ('LOAD_CONST', 0, 1),
+ ('LOAD_CONST', 1, 2),
('LOAD_CONST', 2, 3),
- ('SWAP', 3, 4),
- ('STORE_FAST_STORE_FAST', 17, 4),
+ ('STORE_FAST', 1, 4),
+ ('STORE_FAST', 1, 4),
+ ('STORE_FAST', 1, 4),
+ ('RETURN_VALUE', 5)
+ ]
+ expected_insts = [
+ ('LOAD_CONST', 0, 1),
+ ('LOAD_CONST', 1, 2),
+ ('NOP', 0, 3),
('POP_TOP', 0, 4),
+ ('STORE_FAST', 1, 4),
('RETURN_VALUE', 5)
]
self.cfg_optimization_test(insts, expected_insts, consts=list(range(3)), nlocals=1)
+ def test_no_dead_store_elimination_in_different_lineno(self):
+ insts = [
+ ('LOAD_CONST', 0, 1),
+ ('LOAD_CONST', 1, 2),
+ ('LOAD_CONST', 2, 3),
+ ('STORE_FAST', 1, 4),
+ ('STORE_FAST', 1, 5),
+ ('STORE_FAST', 1, 6),
+ ('RETURN_VALUE', 5)
+ ]
+ self.cfg_optimization_test(insts, insts, consts=list(range(3)), nlocals=1)
+
+
if __name__ == "__main__":
unittest.main()