Skip to content

Commit 9d98958

Browse files
Fidget-Spinnerwoodruffw
authored andcommitted
pythongh-115859: Disable the tier 2 redundancy eliminator by default (pythonGH-115860)
1 parent 6416271 commit 9d98958

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Lib/test/test_capi/test_opt.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import textwrap
55
import unittest
66
import gc
7+
import os
78

89
import _testinternalcapi
910

@@ -568,6 +569,8 @@ def testfunc(n):
568569
count = ops.count("_GUARD_IS_TRUE_POP") + ops.count("_GUARD_IS_FALSE_POP")
569570
self.assertLessEqual(count, 2)
570571

572+
573+
@unittest.skipIf(os.getenv("PYTHONUOPSOPTIMIZE", default=0) == 0, "Needs uop optimizer to run.")
571574
class TestUopsOptimization(unittest.TestCase):
572575

573576
def _run_with_optimizer(self, testfunc, arg):

Python/optimizer_analysis.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,12 @@ _Py_uop_analyze_and_optimize(
810810

811811
peephole_opt(frame, buffer, buffer_size);
812812

813-
err = uop_redundancy_eliminator(
814-
(PyCodeObject *)frame->f_executable, buffer,
815-
buffer_size, curr_stacklen, dependencies);
813+
char *uop_optimize = Py_GETENV("PYTHONUOPSOPTIMIZE");
814+
if (uop_optimize != NULL && *uop_optimize > '0') {
815+
err = uop_redundancy_eliminator(
816+
(PyCodeObject *)frame->f_executable, buffer,
817+
buffer_size, curr_stacklen, dependencies);
818+
}
816819

817820
if (err == 0) {
818821
goto not_ready;

0 commit comments

Comments
 (0)