Skip to content

Commit

Permalink
pythongh-115859: Disable the tier 2 redundancy eliminator by default (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fidget-Spinner authored and woodruffw committed Mar 4, 2024
1 parent 6416271 commit 9d98958
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import textwrap
import unittest
import gc
import os

import _testinternalcapi

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


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

def _run_with_optimizer(self, testfunc, arg):
Expand Down
9 changes: 6 additions & 3 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,12 @@ _Py_uop_analyze_and_optimize(

peephole_opt(frame, buffer, buffer_size);

err = uop_redundancy_eliminator(
(PyCodeObject *)frame->f_executable, buffer,
buffer_size, curr_stacklen, dependencies);
char *uop_optimize = Py_GETENV("PYTHONUOPSOPTIMIZE");
if (uop_optimize != NULL && *uop_optimize > '0') {
err = uop_redundancy_eliminator(
(PyCodeObject *)frame->f_executable, buffer,
buffer_size, curr_stacklen, dependencies);
}

if (err == 0) {
goto not_ready;
Expand Down

0 comments on commit 9d98958

Please sign in to comment.