mirror of
https://github.com/python/cpython.git
synced 2026-01-29 18:52:38 +00:00
gh-130415: Narrowing to constants in branches involving is comparisons with a constant (GH-143895)
This commit is contained in:
parent
6181b69970
commit
0b08438ea6
7 changed files with 241 additions and 20 deletions
|
|
@ -38,6 +38,8 @@ typedef struct _Py_UOpsAbstractFrame _Py_UOpsAbstractFrame;
|
|||
#define sym_new_compact_int _Py_uop_sym_new_compact_int
|
||||
#define sym_is_compact_int _Py_uop_sym_is_compact_int
|
||||
#define sym_new_truthiness _Py_uop_sym_new_truthiness
|
||||
#define sym_new_predicate _Py_uop_sym_new_predicate
|
||||
#define sym_apply_predicate_narrowing _Py_uop_sym_apply_predicate_narrowing
|
||||
|
||||
extern int
|
||||
optimize_to_bool(
|
||||
|
|
@ -533,7 +535,7 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_IS_OP, (left, right -- b, l, r)) {
|
||||
b = sym_new_type(ctx, &PyBool_Type);
|
||||
b = sym_new_predicate(ctx, left, right, (oparg ? JIT_PRED_IS_NOT : JIT_PRED_IS));
|
||||
l = left;
|
||||
r = right;
|
||||
}
|
||||
|
|
@ -1173,6 +1175,8 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_GUARD_IS_TRUE_POP, (flag -- )) {
|
||||
sym_apply_predicate_narrowing(ctx, flag, true);
|
||||
|
||||
if (sym_is_const(ctx, flag)) {
|
||||
PyObject *value = sym_get_const(ctx, flag);
|
||||
assert(value != NULL);
|
||||
|
|
@ -1191,6 +1195,8 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_GUARD_IS_FALSE_POP, (flag -- )) {
|
||||
sym_apply_predicate_narrowing(ctx, flag, false);
|
||||
|
||||
if (sym_is_const(ctx, flag)) {
|
||||
PyObject *value = sym_get_const(ctx, flag);
|
||||
assert(value != NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue