You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Perform "peephole" optimization directly on control-flow graph. #85495
+1 This looks like a nice improvement. I've long wanted the optimizations to be moved upstream.
At the time the peephole logic was first written, operating directly on the code object was the only option that kept optimizations separate from the core compiler logic. But disassembling and reassembling bytecode was always awkward — it is nice to no longer have to do so.
Activity
markshannon commentedon Jul 17, 2020
Currently we perform various bytecode improvements as a pass on the code objects after generating the code object.
This requires parsing the bytecode to find instructions, recreating the CFG, and rewriting the line number table.
If we perform the optimizations directly on the CFG we can avoid all that additional work.
This would save hundreds of lines of code and avoid coupling the optimization to the line number table format.
rhettinger commentedon Jul 17, 2020
+1 This looks like a nice improvement. I've long wanted the optimizations to be moved upstream.
At the time the peephole logic was first written, operating directly on the code object was the only option that kept optimizations separate from the core compiler logic. But disassembling and reassembling bytecode was always awkward — it is nice to no longer have to do so.
markshannon commentedon Jul 30, 2020
New changeset 6e8128f by Mark Shannon in branch 'master':
bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-21517)
6e8128f
methane commentedon Apr 16, 2021
New changeset 8a232c7 by Inada Naoki in branch 'master':
bpo-41323: compiler: Reuse tuple in constant tuple folding (GH-25419)
8a232c7