This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: small improvement for peephole conditional jump optimizer
Type: Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: doublep, rhettinger
Priority: normal Keywords: patch

Created on 2007-08-01 15:48 by doublep, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
conditional-jump-optimization.diff doublep, 2007-08-01 15:48 patch
Messages (2)
msg52974 - (view) Author: Paul Pogonyshev (doublep) Date: 2007-08-01 15:48
This tiny patch adds optimization for the case of conditional jump to UNARY_NOT followed by another conditional jump.  Those NOTs are optimized in turn, but this happens later in peephole pass, so this patch does make difference.

Net improvement is that jump branches can become shorter by a command sometimes.  Bytecode itself shouldn't become shorter, though.
msg67566 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-05-31 05:20
This one does give a real speedup in the case of jumping to a UNARY_NOT 
followed by another conditional jump.

My only issue is that it doesn't make it's transformation all at once.  
It relies on a subsequent pass to not change its assumptions.  This 
tightly couples two pieces of peephole logic that are best left fully 
orthogonal lest we introduct maintenance problems.  The fragility is 
compounded because a new basic block is formed and that is not recorded 
in the structure designed to track the blocks.

At some point, many of the peephole optimizations are going to be moved 
upstream into a AST optimizer.  That is a more appropriate place for 
this kind of transformation.

Am closing this because it makes the code too fragile, but I think the 
idea was inspired and the implementation was clever.  Thanks for the 
patch.
History
Date User Action Args
2022-04-11 14:56:25adminsetgithub: 45267
2008-05-31 05:20:59rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg67566
nosy: + rhettinger
2007-08-24 11:49:06georg.brandlsetassignee: rhettinger
2007-08-01 15:48:29doublepcreate