mirror of https://github.com/python/cpython
GH-115687: Most comparisons create Booleans, so propagate that information (GH-116360)
Most comparisons create booleans
This commit is contained in:
parent
2b379968e5
commit
33c0aa3bb9
|
@ -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)) {
|
op(_LOAD_CONST, (-- value)) {
|
||||||
// There should be no LOAD_CONST. It should be all
|
// There should be no LOAD_CONST. It should be all
|
||||||
// replaced by peephole_opt.
|
// replaced by peephole_opt.
|
||||||
|
|
|
@ -1130,55 +1130,78 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
case _COMPARE_OP: {
|
case _COMPARE_OP: {
|
||||||
|
_Py_UopsSymbol *right;
|
||||||
|
_Py_UopsSymbol *left;
|
||||||
_Py_UopsSymbol *res;
|
_Py_UopsSymbol *res;
|
||||||
res = sym_new_unknown(ctx);
|
right = stack_pointer[-1];
|
||||||
if (res == NULL) goto out_of_space;
|
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[-2] = res;
|
||||||
stack_pointer += -1;
|
stack_pointer += -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case _COMPARE_OP_FLOAT: {
|
case _COMPARE_OP_FLOAT: {
|
||||||
|
_Py_UopsSymbol *right;
|
||||||
|
_Py_UopsSymbol *left;
|
||||||
_Py_UopsSymbol *res;
|
_Py_UopsSymbol *res;
|
||||||
res = sym_new_unknown(ctx);
|
right = stack_pointer[-1];
|
||||||
if (res == NULL) goto out_of_space;
|
left = stack_pointer[-2];
|
||||||
|
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
stack_pointer += -1;
|
stack_pointer += -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case _COMPARE_OP_INT: {
|
case _COMPARE_OP_INT: {
|
||||||
|
_Py_UopsSymbol *right;
|
||||||
|
_Py_UopsSymbol *left;
|
||||||
_Py_UopsSymbol *res;
|
_Py_UopsSymbol *res;
|
||||||
res = sym_new_unknown(ctx);
|
right = stack_pointer[-1];
|
||||||
if (res == NULL) goto out_of_space;
|
left = stack_pointer[-2];
|
||||||
|
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
stack_pointer += -1;
|
stack_pointer += -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case _COMPARE_OP_STR: {
|
case _COMPARE_OP_STR: {
|
||||||
|
_Py_UopsSymbol *right;
|
||||||
|
_Py_UopsSymbol *left;
|
||||||
_Py_UopsSymbol *res;
|
_Py_UopsSymbol *res;
|
||||||
res = sym_new_unknown(ctx);
|
right = stack_pointer[-1];
|
||||||
if (res == NULL) goto out_of_space;
|
left = stack_pointer[-2];
|
||||||
|
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
|
||||||
stack_pointer[-2] = res;
|
stack_pointer[-2] = res;
|
||||||
stack_pointer += -1;
|
stack_pointer += -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case _IS_OP: {
|
case _IS_OP: {
|
||||||
_Py_UopsSymbol *b;
|
_Py_UopsSymbol *right;
|
||||||
b = sym_new_unknown(ctx);
|
_Py_UopsSymbol *left;
|
||||||
if (b == NULL) goto out_of_space;
|
_Py_UopsSymbol *res;
|
||||||
stack_pointer[-2] = b;
|
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;
|
stack_pointer += -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case _CONTAINS_OP: {
|
case _CONTAINS_OP: {
|
||||||
_Py_UopsSymbol *b;
|
_Py_UopsSymbol *right;
|
||||||
b = sym_new_unknown(ctx);
|
_Py_UopsSymbol *left;
|
||||||
if (b == NULL) goto out_of_space;
|
_Py_UopsSymbol *res;
|
||||||
stack_pointer[-2] = b;
|
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;
|
stack_pointer += -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue