bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-21517)
* Move 'peephole' optimizations into compile.c and perform them directly on the CFG.
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 7913e91..65047ca 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -416,9 +416,9 @@
if cond1: return 4
self.assertNotInBytecode(f, 'JUMP_FORWARD')
# There should be one jump for the while loop.
- returns = [instr for instr in dis.get_instructions(f)
- if instr.opname == 'JUMP_ABSOLUTE']
- self.assertEqual(len(returns), 1)
+ jumps = [instr for instr in dis.get_instructions(f)
+ if 'JUMP' in instr.opname]
+ self.assertEqual(len(jumps), 1)
returns = [instr for instr in dis.get_instructions(f)
if instr.opname == 'RETURN_VALUE']
self.assertLessEqual(len(returns), 2)