mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
GH-130415: Narrow int to 0 based on boolean tests (GH-130772)
This commit is contained in:
parent
e20e47dda6
commit
c989e74446
6 changed files with 38 additions and 2 deletions
|
@ -406,7 +406,7 @@ dummy_func(void) {
|
|||
op(_TO_BOOL_INT, (value -- res)) {
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
sym_set_type(value, &PyLong_Type);
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
Python/optimizer_cases.c.h
generated
2
Python/optimizer_cases.c.h
generated
|
@ -178,7 +178,7 @@
|
|||
value = stack_pointer[-1];
|
||||
if (!optimize_to_bool(this_instr, ctx, value, &res)) {
|
||||
sym_set_type(value, &PyLong_Type);
|
||||
res = sym_new_type(ctx, &PyBool_Type);
|
||||
res = sym_new_truthiness(ctx, value, true);
|
||||
}
|
||||
stack_pointer[-1] = res;
|
||||
break;
|
||||
|
|
|
@ -299,6 +299,9 @@ _Py_uop_sym_set_const(JitOptContext *ctx, JitOptSymbol *sym, PyObject *const_val
|
|||
else if (type == &PyBool_Type) {
|
||||
_Py_uop_sym_set_const(ctx, value, Py_False);
|
||||
}
|
||||
else if (type == &PyLong_Type) {
|
||||
_Py_uop_sym_set_const(ctx, value, Py_GetConstant(Py_CONSTANT_ZERO));
|
||||
}
|
||||
// TODO: More types (GH-130415)!
|
||||
make_const(sym, const_val);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue