GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement simple dead store elimination in cfg opt · corona10/cpython@477a02c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib/test
    • test_dis.py
    • test_peepholer.py
  • Python
    • flowgraph.c
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_dis.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_dis.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def extended_arg_quick():
811811
%3d 2 LOAD_CONST 1 (Ellipsis)
812812
4 EXTENDED_ARG 1
813813
6 UNPACK_EX 256
814-
8 STORE_FAST 0 (_)
814+
8 POP_TOP
815815
10 STORE_FAST 0 (_)
816816
12 RETURN_CONST 0 (None)
817817
"""% (extended_arg_quick.__code__.co_firstlineno,
Collapse file

‎Lib/test/test_peepholer.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_peepholer.py
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,17 @@ def test_no_unsafe_static_swap(self):
10711071
('POP_TOP', 0, 4),
10721072
('RETURN_VALUE', 5)
10731073
]
1074-
self.cfg_optimization_test(insts, insts, consts=list(range(3)), nlocals=1)
1074+
expected_insts = [
1075+
('LOAD_CONST', 0, 1),
1076+
('LOAD_CONST', 1, 2),
1077+
('LOAD_CONST', 2, 3),
1078+
('SWAP', 3, 4),
1079+
('POP_TOP', 0, 4),
1080+
('STORE_FAST', 1, 4),
1081+
('POP_TOP', 0, 4),
1082+
('RETURN_VALUE', 5)
1083+
]
1084+
self.cfg_optimization_test(insts, expected_insts, consts=list(range(3)), nlocals=1)
10751085

10761086
if __name__ == "__main__":
10771087
unittest.main()
Collapse file

‎Python/flowgraph.c‎

Copy file name to clipboardExpand all lines: Python/flowgraph.c
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,12 @@ optimize_basic_block(PyObject *const_cache, basicblock *bb, PyObject *consts)
15151515
*/
15161516
}
15171517
break;
1518+
case STORE_FAST:
1519+
if (opcode == nextop && oparg == bb->b_instr[i+1].i_oparg) {
1520+
bb->b_instr[i].i_opcode = POP_TOP;
1521+
bb->b_instr[i].i_oparg = 0;
1522+
}
1523+
break;
15181524
case SWAP:
15191525
if (oparg == 1) {
15201526
INSTR_SET_OP0(inst, NOP);

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.