Skip to content

Commit aea0b91

Browse files
authored
gh-148211: decompose [_POP_CALL_X/_SHUFFLE_2]_LOAD_CONST_INLINE_BORROW in JIT (GH-148313)
1 parent d3b7b93 commit aea0b91

File tree

8 files changed

+1040
-1411
lines changed

8 files changed

+1040
-1411
lines changed

Include/internal/pycore_uop_ids.h

Lines changed: 1023 additions & 1034 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 0 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_capi/test_opt.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,14 +2454,8 @@ def testfunc(n):
24542454
self.assertEqual(res, TIER2_THRESHOLD)
24552455
self.assertIsNotNone(ex)
24562456
uops = get_opnames(ex)
2457-
# When the result of type(...) is known, _CALL_TYPE_1 is replaced with
2458-
# _SHUFFLE_2_LOAD_CONST_INLINE_BORROW which is optimized away in
2459-
# remove_unneeded_uops.
2457+
# When the result of type(...) is known, _CALL_TYPE_1 is decomposed.
24602458
self.assertNotIn("_CALL_TYPE_1", uops)
2461-
self.assertNotIn("_SHUFFLE_2_LOAD_CONST_INLINE_BORROW", uops)
2462-
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
2463-
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
2464-
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
24652459

24662460
def test_call_type_1_result_is_const(self):
24672461
def testfunc(n):
@@ -2685,9 +2679,6 @@ def testfunc(n):
26852679
# When the length is < _PY_NSMALLPOSINTS, the len() call is replaced
26862680
# with just an inline load.
26872681
self.assertNotIn("_CALL_LEN", uops)
2688-
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
2689-
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
2690-
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
26912682

26922683
def test_call_len_known_length(self):
26932684
# Make sure that len(t) is not optimized for a tuple of length 2048.
@@ -2960,10 +2951,6 @@ def testfunc(n):
29602951
self.assertNotIn("_CALL_ISINSTANCE", uops)
29612952
self.assertNotIn("_GUARD_THIRD_NULL", uops)
29622953
self.assertNotIn("_GUARD_CALLABLE_ISINSTANCE", uops)
2963-
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
2964-
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
2965-
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
2966-
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
29672954

29682955
def test_call_list_append(self):
29692956
def testfunc(n):
@@ -3006,9 +2993,6 @@ def testfunc(n):
30062993
self.assertNotIn("_TO_BOOL_BOOL", uops)
30072994
self.assertNotIn(self.guard_is_true, uops)
30082995
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
3009-
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
3010-
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
3011-
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
30122996

30132997
def test_call_isinstance_is_false(self):
30142998
def testfunc(n):
@@ -3027,9 +3011,6 @@ def testfunc(n):
30273011
self.assertNotIn("_TO_BOOL_BOOL", uops)
30283012
self.assertNotIn(self.guard_is_false, uops)
30293013
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
3030-
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
3031-
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
3032-
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
30333014

30343015
def test_call_isinstance_subclass(self):
30353016
def testfunc(n):
@@ -3048,9 +3029,6 @@ def testfunc(n):
30483029
self.assertNotIn("_TO_BOOL_BOOL", uops)
30493030
self.assertNotIn(self.guard_is_true, uops)
30503031
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
3051-
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
3052-
self.assertNotIn("_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW", uops)
3053-
self.assertNotIn("_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW", uops)
30543032

30553033
def test_call_isinstance_unknown_object(self):
30563034
def testfunc(n):

Python/bytecodes.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5936,50 +5936,20 @@ dummy_func(
59365936
value = PyStackRef_FromPyObjectBorrow(ptr);
59375937
}
59385938

5939-
tier2 op(_POP_CALL_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null -- value)) {
5940-
(void)null; // Silence compiler warnings about unused variables
5941-
DEAD(null);
5942-
PyStackRef_CLOSE(callable);
5943-
value = PyStackRef_FromPyObjectBorrow(ptr);
5944-
}
5945-
5946-
tier2 op(_POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, pop -- value)) {
5947-
PyStackRef_CLOSE(pop);
5948-
(void)null; // Silence compiler warnings about unused variables
5949-
DEAD(null);
5950-
PyStackRef_CLOSE(callable);
5951-
value = PyStackRef_FromPyObjectBorrow(ptr);
5952-
}
5953-
59545939
tier2 op(_INSERT_2_LOAD_CONST_INLINE_BORROW, (ptr/4, left, right -- res, l, r)) {
59555940
res = PyStackRef_FromPyObjectBorrow(ptr);
59565941
l = left;
59575942
r = right;
59585943
INPUTS_DEAD();
59595944
}
59605945

5961-
tier2 op(_SHUFFLE_2_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, arg -- res, a)) {
5962-
res = PyStackRef_FromPyObjectBorrow(ptr);
5963-
a = arg;
5964-
INPUTS_DEAD();
5965-
}
5966-
59675946
tier2 op(_SHUFFLE_3_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, arg -- res, a, c)) {
59685947
res = PyStackRef_FromPyObjectBorrow(ptr);
59695948
a = arg;
59705949
c = callable;
59715950
INPUTS_DEAD();
59725951
}
59735952

5974-
tier2 op(_POP_CALL_TWO_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, pop1, pop2 -- value)) {
5975-
PyStackRef_CLOSE(pop2);
5976-
PyStackRef_CLOSE(pop1);
5977-
(void)null; // Silence compiler warnings about unused variables
5978-
DEAD(null);
5979-
PyStackRef_CLOSE(callable);
5980-
value = PyStackRef_FromPyObjectBorrow(ptr);
5981-
}
5982-
59835953
tier2 op(_START_EXECUTOR, (executor/4 --)) {
59845954
#ifndef _Py_JIT
59855955
assert(current_executor == (_PyExecutorObject*)executor);

0 commit comments

Comments
 (0)