diff options
author | Mark Shannon <mark@hotpy.org> | 2024-03-06 10:46:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 10:46:42 (GMT) |
commit | 33c0aa3bb9b334593e27fe4b2b0fe912117a1ee1 (patch) | |
tree | f6b571f51b67823a157102b2273ad0029c87ffc7 /Python/optimizer_bytecodes.c | |
parent | 2b379968e554f9ce0832e84f5f8a85131a3be35e (diff) | |
download | cpython-33c0aa3bb9b334593e27fe4b2b0fe912117a1ee1.zip cpython-33c0aa3bb9b334593e27fe4b2b0fe912117a1ee1.tar.gz cpython-33c0aa3bb9b334593e27fe4b2b0fe912117a1ee1.tar.bz2 |
GH-115687: Most comparisons create Booleans, so propagate that information (GH-116360)
Most comparisons create booleans
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r-- | Python/optimizer_bytecodes.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index ee67a2b..07a1adb 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -351,6 +351,35 @@ dummy_func(void) { } } + op(_COMPARE_OP, (left, right -- res)) { + if (oparg & 16) { + OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type)); + } + else { + OUT_OF_SPACE_IF_NULL(res = _Py_uop_sym_new_not_null(ctx)); + } + } + + op(_COMPARE_OP_INT, (left, right -- res)) { + OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type)); + } + + op(_COMPARE_OP_FLOAT, (left, right -- res)) { + OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type)); + } + + op(_COMPARE_OP_STR, (left, right -- res)) { + OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type)); + } + + op(_IS_OP, (left, right -- res)) { + OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type)); + } + + op(_CONTAINS_OP, (left, right -- res)) { + OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type)); + } + op(_LOAD_CONST, (-- value)) { // There should be no LOAD_CONST. It should be all // replaced by peephole_opt. |