diff options
| author | Mark Shannon <mark@hotpy.org> | 2024-04-22 12:34:06 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-22 12:34:06 (GMT) |
| commit | a6647d16abf4dd65997865e857371673238e60bf (patch) | |
| tree | b4ebfbfb86f0962d766f09d3d54513a9b38b0669 /Python/optimizer_symbols.c | |
| parent | ceb6038b053c403bed3ca3a8bd17b7e3fc9aab7d (diff) | |
| download | cpython-a6647d16abf4dd65997865e857371673238e60bf.zip cpython-a6647d16abf4dd65997865e857371673238e60bf.tar.gz cpython-a6647d16abf4dd65997865e857371673238e60bf.tar.bz2 | |
GH-115480: Reduce guard strength for binary ops when type of one operand is known already (GH-118050)
Diffstat (limited to 'Python/optimizer_symbols.c')
| -rw-r--r-- | Python/optimizer_symbols.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/optimizer_symbols.c b/Python/optimizer_symbols.c index 86b0d4d..204599b 100644 --- a/Python/optimizer_symbols.c +++ b/Python/optimizer_symbols.c @@ -231,6 +231,15 @@ _Py_uop_sym_new_null(_Py_UOpsContext *ctx) return null_sym; } +PyTypeObject * +_Py_uop_sym_get_type(_Py_UopsSymbol *sym) +{ + if (_Py_uop_sym_is_bottom(sym)) { + return NULL; + } + return sym->typ; +} + bool _Py_uop_sym_has_type(_Py_UopsSymbol *sym) { @@ -244,10 +253,7 @@ bool _Py_uop_sym_matches_type(_Py_UopsSymbol *sym, PyTypeObject *typ) { assert(typ != NULL && PyType_Check(typ)); - if (_Py_uop_sym_is_bottom(sym)) { - return false; - } - return sym->typ == typ; + return _Py_uop_sym_get_type(sym) == typ; } int |
