summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-03-06 10:46:42 (GMT)
committerGitHub <noreply@github.com>2024-03-06 10:46:42 (GMT)
commit33c0aa3bb9b334593e27fe4b2b0fe912117a1ee1 (patch)
treef6b571f51b67823a157102b2273ad0029c87ffc7 /Python/optimizer_cases.c.h
parent2b379968e554f9ce0832e84f5f8a85131a3be35e (diff)
downloadcpython-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_cases.c.h')
-rw-r--r--Python/optimizer_cases.c.h55
1 files changed, 39 insertions, 16 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index 4ed1ac9..32dfca9 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -1130,55 +1130,78 @@
}
case _COMPARE_OP: {
+ _Py_UopsSymbol *right;
+ _Py_UopsSymbol *left;
_Py_UopsSymbol *res;
- res = sym_new_unknown(ctx);
- if (res == NULL) goto out_of_space;
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ 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));
+ }
stack_pointer[-2] = res;
stack_pointer += -1;
break;
}
case _COMPARE_OP_FLOAT: {
+ _Py_UopsSymbol *right;
+ _Py_UopsSymbol *left;
_Py_UopsSymbol *res;
- res = sym_new_unknown(ctx);
- if (res == NULL) goto out_of_space;
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
stack_pointer[-2] = res;
stack_pointer += -1;
break;
}
case _COMPARE_OP_INT: {
+ _Py_UopsSymbol *right;
+ _Py_UopsSymbol *left;
_Py_UopsSymbol *res;
- res = sym_new_unknown(ctx);
- if (res == NULL) goto out_of_space;
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
stack_pointer[-2] = res;
stack_pointer += -1;
break;
}
case _COMPARE_OP_STR: {
+ _Py_UopsSymbol *right;
+ _Py_UopsSymbol *left;
_Py_UopsSymbol *res;
- res = sym_new_unknown(ctx);
- if (res == NULL) goto out_of_space;
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
stack_pointer[-2] = res;
stack_pointer += -1;
break;
}
case _IS_OP: {
- _Py_UopsSymbol *b;
- b = sym_new_unknown(ctx);
- if (b == NULL) goto out_of_space;
- stack_pointer[-2] = b;
+ _Py_UopsSymbol *right;
+ _Py_UopsSymbol *left;
+ _Py_UopsSymbol *res;
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
+ stack_pointer[-2] = res;
stack_pointer += -1;
break;
}
case _CONTAINS_OP: {
- _Py_UopsSymbol *b;
- b = sym_new_unknown(ctx);
- if (b == NULL) goto out_of_space;
- stack_pointer[-2] = b;
+ _Py_UopsSymbol *right;
+ _Py_UopsSymbol *left;
+ _Py_UopsSymbol *res;
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
+ stack_pointer[-2] = res;
stack_pointer += -1;
break;
}