8000 reduce diff, add tests · python/cpython@e34a0f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit e34a0f5

Browse files
reduce diff, add tests
1 parent c55ba14 commit e34a0f5

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,30 @@ def testfunc(loops):
568568
self.assertGreaterEqual(len(binop_count), 3)
569569
self.assertLessEqual(len(guard_both_int_count), 1)
570570

571+
def test_int_type_propagation_through_frame(self):
572+
def double(x):
573+
return x + x
574+
def testfunc(loops):
575+
num = 0
576+
while num < loops:
577+
x = num + num
578+
a = double(x)
579+
num += 1
580+
return a
581+
582+
opt = _testinternalcapi.get_uop_optimizer()
583+
res = None
584+
with temporary_optimizer(opt):
585+
res = testfunc(32)
586+
587+
ex = get_first_executor(testfunc)
588+
self.assertIsNotNone(ex)
589+
self.assertEqual(res, 124)
590+
binop_count = [opname for opname, _, _ in ex if opname == "_BINARY_OP_ADD_INT"]
591+
guard_both_int_count = [opname for opname, _, _ in ex if opname == "_GUARD_BOTH_INT"]
592+
self.assertGreaterEqual(len(binop_count), 3)
593+
self.assertLessEqual(len(guard_both_int_count), 1)
594+
571595
def test_int_impure_region(self):
572596
def testfunc(loops):
573597
num = 0
@@ -705,9 +729,5 @@ def testfunc(n):
705729

706730

707731

708-
class Foo:
709-
attr = 1
710-
711-
712732
if __name__ == "__main__":
713733
unittest.main()

Python/optimizer_analysis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ emit_i(uops_emitter *emitter,
551551

552552

553553
#ifndef Py_DEBUG
554-
#define GETITEM(ctx, i) Py_UNREACHABLE();
554+
#define GETITEM(ctx, i) (_Py_UOpsSymType *)Py_UNREACHABLE();
555555
#else
556556
static inline _Py_UOpsSymType *
557557
GETITEM(_Py_UOpsAbstractInterpContext *ctx, Py_ssize_t i) {

Python/pylifecycle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ init_interp_main(PyThreadState *tstate)
12521252
if (_Py_get_xoption(&config->xoptions, L"uops") != NULL) {
12531253
enabled = 1;
12541254
}
1255-
enabled = 1; // TEMPORARY: always enable
1255+
12561256
if (enabled) {
12571257
#else
12581258
// Always enable tier two for JIT builds (ignoring the environment

Tools/cases_generator/analyzer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import parser
44
from typing import Optional
55

6+
67
@dataclass
78
class Properties:
89
escapes: bool

0 commit comments

Comments
 (0)
0