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/bytecodes.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/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index b7511b9..4541eb6 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -426,6 +426,14 @@ dummy_func( EXIT_IF(!PyLong_CheckExact(right)); } + op(_GUARD_NOS_INT, (left, unused -- left, unused)) { + EXIT_IF(!PyLong_CheckExact(left)); + } + + op(_GUARD_TOS_INT, (value -- value)) { + EXIT_IF(!PyLong_CheckExact(value)); + } + pure op(_BINARY_OP_MULTIPLY_INT, (left, right -- res)) { STAT_INC(BINARY_OP, hit); res = _PyLong_Multiply((PyLongObject *)left, (PyLongObject *)right); @@ -462,6 +470,14 @@ dummy_func( EXIT_IF(!PyFloat_CheckExact(right)); } + op(_GUARD_NOS_FLOAT, (left, unused -- left, unused)) { + EXIT_IF(!PyFloat_CheckExact(left)); + } + + op(_GUARD_TOS_FLOAT, (value -- value)) { + EXIT_IF(!PyFloat_CheckExact(value)); + } + pure op(_BINARY_OP_MULTIPLY_FLOAT, (left, right -- res)) { STAT_INC(BINARY_OP, hit); double dres = |