GH-131798: Optimize away type(x) in the JIT when the result is known (GH-135194)

This commit is contained in:
Tomas R.
2025-06-07 01:44:43 +02:00
committed by GitHub
parent f00512db20
commit 46151648ca
4 changed files with 36 additions and 9 deletions
+5 -2
View File
@@ -937,8 +937,11 @@ dummy_func(void) {
}
op(_CALL_TYPE_1, (unused, unused, arg -- res)) {
if (sym_has_type(arg)) {
res = sym_new_const(ctx, (PyObject *)sym_get_type(arg));
PyObject* type = (PyObject *)sym_get_type(arg);
if (type) {
res = sym_new_const(ctx, type);
REPLACE_OP(this_instr, _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW, 0,
(uintptr_t)type);
}
else {
res = sym_new_not_null(ctx);