GH-115819: Eliminate Boolean guards when value is known (GH-116355)

This commit is contained in:
Mark Shannon 2024-03-05 15:06:00 +00:00 committed by GitHub
parent c91bdf86ef
commit 0c81ce1360
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 102 additions and 2 deletions

View file

@ -292,6 +292,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
#define sym_is_null _Py_uop_sym_is_null
#define sym_new_const _Py_uop_sym_new_const
#define sym_new_null _Py_uop_sym_new_null
#define sym_has_type _Py_uop_sym_has_type
#define sym_matches_type _Py_uop_sym_matches_type
#define sym_set_null _Py_uop_sym_set_null
#define sym_set_non_null _Py_uop_sym_set_non_null
@ -324,6 +325,16 @@ optimize_to_bool(
return 0;
}
static void
eliminate_pop_guard(_PyUOpInstruction *this_instr, bool exit)
{
REPLACE_OP(this_instr, _POP_TOP, 0, 0);
if (exit) {
REPLACE_OP((this_instr+1), _EXIT_TRACE, 0, 0);
this_instr[1].target = this_instr->target;
}
}
/* 1 for success, 0 for not ready, cannot error at the moment. */
static int
optimize_uops(