diff options
author | Dong-hee Na <donghee.na@python.org> | 2023-06-07 23:39:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-07 23:39:56 (GMT) |
commit | aa5b762bd3a3e837678cf7f9e1434c0f68208a0e (patch) | |
tree | ffd19de4a3f175d02f812b12166b0568525e0c27 /Lib/test/test_peepholer.py | |
parent | ffeaec7e60c88d585deacb10264ba7a96e5e52df (diff) | |
download | cpython-aa5b762bd3a3e837678cf7f9e1434c0f68208a0e.zip cpython-aa5b762bd3a3e837678cf7f9e1434c0f68208a0e.tar.gz cpython-aa5b762bd3a3e837678cf7f9e1434c0f68208a0e.tar.bz2 |
gh-104635: Eliminate redundant STORE_FAST instructions in the compiler (gh-105320)
Diffstat (limited to 'Lib/test/test_peepholer.py')
-rw-r--r-- | Lib/test/test_peepholer.py | 36 |
1 files changed, 34 insertions, 2 deletions
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() |