mirror of
https://github.com/python/cpython.git
synced 2026-05-06 04:37:33 -04:00
gh-148211: decompose _SHUFFLE_3_LOAD_CONST_INLINE_BORROW in JIT (GH-148816)
This commit is contained in:
Generated
+1018
-1023
File diff suppressed because it is too large
Load Diff
Generated
-21
@@ -397,7 +397,6 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = {
|
||||
[_CHECK_VALIDITY] = HAS_DEOPT_FLAG,
|
||||
[_LOAD_CONST_INLINE] = HAS_PURE_FLAG,
|
||||
[_LOAD_CONST_INLINE_BORROW] = HAS_PURE_FLAG,
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW] = 0,
|
||||
[_START_EXECUTOR] = HAS_DEOPT_FLAG,
|
||||
[_MAKE_WARM] = 0,
|
||||
[_FATAL_ERROR] = 0,
|
||||
@@ -3700,15 +3699,6 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = {
|
||||
{ -1, -1, -1 },
|
||||
},
|
||||
},
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW] = {
|
||||
.best = { 0, 1, 2, 3 },
|
||||
.entries = {
|
||||
{ 3, 0, _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03 },
|
||||
{ 3, 1, _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13 },
|
||||
{ 3, 2, _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23 },
|
||||
{ 3, 3, _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33 },
|
||||
},
|
||||
},
|
||||
[_START_EXECUTOR] = {
|
||||
.best = { 0, 0, 0, 0 },
|
||||
.entries = {
|
||||
@@ -4705,10 +4695,6 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = {
|
||||
[_LOAD_CONST_INLINE_BORROW_r01] = _LOAD_CONST_INLINE_BORROW,
|
||||
[_LOAD_CONST_INLINE_BORROW_r12] = _LOAD_CONST_INLINE_BORROW,
|
||||
[_LOAD_CONST_INLINE_BORROW_r23] = _LOAD_CONST_INLINE_BORROW,
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW,
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW,
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW,
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33] = _SHUFFLE_3_LOAD_CONST_INLINE_BORROW,
|
||||
[_START_EXECUTOR_r00] = _START_EXECUTOR,
|
||||
[_MAKE_WARM_r00] = _MAKE_WARM,
|
||||
[_MAKE_WARM_r11] = _MAKE_WARM,
|
||||
@@ -5933,11 +5919,6 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = {
|
||||
[_SET_IP_r33] = "_SET_IP_r33",
|
||||
[_SET_UPDATE] = "_SET_UPDATE",
|
||||
[_SET_UPDATE_r11] = "_SET_UPDATE_r11",
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW",
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03",
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13",
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23",
|
||||
[_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33] = "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33",
|
||||
[_SPILL_OR_RELOAD] = "_SPILL_OR_RELOAD",
|
||||
[_SPILL_OR_RELOAD_r01] = "_SPILL_OR_RELOAD_r01",
|
||||
[_SPILL_OR_RELOAD_r02] = "_SPILL_OR_RELOAD_r02",
|
||||
@@ -6827,8 +6808,6 @@ int _PyUop_num_popped(int opcode, int oparg)
|
||||
return 0;
|
||||
case _LOAD_CONST_INLINE_BORROW:
|
||||
return 0;
|
||||
case _SHUFFLE_3_LOAD_CONST_INLINE_BORROW:
|
||||
return 3;
|
||||
case _START_EXECUTOR:
|
||||
return 0;
|
||||
case _MAKE_WARM:
|
||||
|
||||
@@ -2963,7 +2963,7 @@ class TestUopsOptimization(unittest.TestCase):
|
||||
self.assertIsNotNone(ex)
|
||||
uops = get_opnames(ex)
|
||||
self.assertNotIn("_CALL_LEN", uops)
|
||||
self.assertEqual(count_ops(ex, "_SHUFFLE_3_LOAD_CONST_INLINE_BORROW"), 4)
|
||||
self.assertGreaterEqual(count_ops(ex, "_LOAD_CONST_INLINE_BORROW"), 8)
|
||||
|
||||
def test_call_len_known_length_small_int(self):
|
||||
# Make sure that len(t) is optimized for a tuple of length 5.
|
||||
|
||||
@@ -6107,13 +6107,6 @@ dummy_func(
|
||||
value = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
}
|
||||
|
||||
tier2 op(_SHUFFLE_3_LOAD_CONST_INLINE_BORROW, (ptr/4, callable, null, arg -- res, a, c)) {
|
||||
res = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
a = arg;
|
||||
c = callable;
|
||||
INPUTS_DEAD();
|
||||
}
|
||||
|
||||
tier2 op(_START_EXECUTOR, (executor/4 --)) {
|
||||
#ifndef _Py_JIT
|
||||
assert(current_executor == (_PyExecutorObject*)executor);
|
||||
|
||||
Generated
-100
@@ -22337,106 +22337,6 @@
|
||||
break;
|
||||
}
|
||||
|
||||
case _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r03: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef arg;
|
||||
_PyStackRef callable;
|
||||
_PyStackRef res;
|
||||
_PyStackRef a;
|
||||
_PyStackRef c;
|
||||
arg = stack_pointer[-1];
|
||||
callable = stack_pointer[-3];
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
res = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
a = arg;
|
||||
c = callable;
|
||||
_tos_cache2 = c;
|
||||
_tos_cache1 = a;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -3;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r13: {
|
||||
CHECK_CURRENT_CACHED_VALUES(1);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef arg;
|
||||
_PyStackRef callable;
|
||||
_PyStackRef res;
|
||||
_PyStackRef a;
|
||||
_PyStackRef c;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
arg = _stack_item_0;
|
||||
callable = stack_pointer[-2];
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
res = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
a = arg;
|
||||
c = callable;
|
||||
_tos_cache2 = c;
|
||||
_tos_cache1 = a;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -2;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r23: {
|
||||
CHECK_CURRENT_CACHED_VALUES(2);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef arg;
|
||||
_PyStackRef callable;
|
||||
_PyStackRef res;
|
||||
_PyStackRef a;
|
||||
_PyStackRef c;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
arg = _stack_item_1;
|
||||
callable = stack_pointer[-1];
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
res = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
a = arg;
|
||||
c = callable;
|
||||
_tos_cache2 = c;
|
||||
_tos_cache1 = a;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
stack_pointer += -1;
|
||||
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _SHUFFLE_3_LOAD_CONST_INLINE_BORROW_r33: {
|
||||
CHECK_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
_PyStackRef arg;
|
||||
_PyStackRef callable;
|
||||
_PyStackRef res;
|
||||
_PyStackRef a;
|
||||
_PyStackRef c;
|
||||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
arg = _stack_item_2;
|
||||
callable = _stack_item_0;
|
||||
PyObject *ptr = (PyObject *)CURRENT_OPERAND0_64();
|
||||
res = PyStackRef_FromPyObjectBorrow(ptr);
|
||||
a = arg;
|
||||
c = callable;
|
||||
_tos_cache2 = c;
|
||||
_tos_cache1 = a;
|
||||
_tos_cache0 = res;
|
||||
SET_CURRENT_CACHED_VALUES(3);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
break;
|
||||
}
|
||||
|
||||
case _START_EXECUTOR_r00: {
|
||||
CHECK_CURRENT_CACHED_VALUES(0);
|
||||
assert(WITHIN_STACK_BOUNDS_IGNORING_CACHE());
|
||||
|
||||
@@ -2330,7 +2330,10 @@ dummy_func(void) {
|
||||
goto error;
|
||||
}
|
||||
if (_Py_IsImmortal(temp)) {
|
||||
ADD_OP(_SHUFFLE_3_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)temp);
|
||||
ADD_OP(_SWAP, 2, 0);
|
||||
optimize_pop_top(ctx, this_instr, null);
|
||||
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)temp);
|
||||
ADD_OP(_SWAP, 3, 0);
|
||||
}
|
||||
res = sym_new_const(ctx, temp);
|
||||
Py_DECREF(temp);
|
||||
|
||||
Generated
+6
-14
@@ -4514,11 +4514,13 @@
|
||||
|
||||
case _CALL_LEN: {
|
||||
JitOptRef arg;
|
||||
JitOptRef null;
|
||||
JitOptRef callable;
|
||||
JitOptRef res;
|
||||
JitOptRef a;
|
||||
JitOptRef c;
|
||||
arg = stack_pointer[-1];
|
||||
null = stack_pointer[-2];
|
||||
callable = stack_pointer[-3];
|
||||
res = sym_new_type(ctx, &PyLong_Type);
|
||||
Py_ssize_t length = sym_tuple_length(arg);
|
||||
@@ -4544,7 +4546,10 @@
|
||||
goto error;
|
||||
}
|
||||
if (_Py_IsImmortal(temp)) {
|
||||
ADD_OP(_SHUFFLE_3_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)temp);
|
||||
ADD_OP(_SWAP, 2, 0);
|
||||
optimize_pop_top(ctx, this_instr, null);
|
||||
ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)temp);
|
||||
ADD_OP(_SWAP, 3, 0);
|
||||
}
|
||||
res = sym_new_const(ctx, temp);
|
||||
CHECK_STACK_BOUNDS(-2);
|
||||
@@ -5497,19 +5502,6 @@
|
||||
break;
|
||||
}
|
||||
|
||||
case _SHUFFLE_3_LOAD_CONST_INLINE_BORROW: {
|
||||
JitOptRef res;
|
||||
JitOptRef a;
|
||||
JitOptRef c;
|
||||
res = sym_new_not_null(ctx);
|
||||
a = sym_new_not_null(ctx);
|
||||
c = sym_new_not_null(ctx);
|
||||
stack_pointer[-3] = res;
|
||||
stack_pointer[-2] = a;
|
||||
stack_pointer[-1] = c;
|
||||
break;
|
||||
}
|
||||
|
||||
case _START_EXECUTOR: {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user