summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_cases.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'Python/optimizer_cases.c.h')
-rw-r--r--Python/optimizer_cases.c.h65
1 files changed, 38 insertions, 27 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index 6d3488f..f2c186a 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -107,24 +107,31 @@
_Py_UopsSymbol *value;
_Py_UopsSymbol *res;
value = stack_pointer[-1];
- (void)value;
- res = sym_new_type(ctx, &PyBool_Type);
- OUT_OF_SPACE_IF_NULL(res);
+ if (optimize_to_bool(this_instr, ctx, value, &res)) {
+ OUT_OF_SPACE_IF_NULL(res);
+ }
+ else {
+ res = sym_new_type(ctx, &PyBool_Type);
+ OUT_OF_SPACE_IF_NULL(res);
+ }
stack_pointer[-1] = res;
break;
}
case _TO_BOOL_BOOL: {
_Py_UopsSymbol *value;
+ _Py_UopsSymbol *res;
value = stack_pointer[-1];
- if (sym_matches_type(value, &PyBool_Type)) {
- REPLACE_OP(this_instr, _NOP, 0, 0);
+ if (optimize_to_bool(this_instr, ctx, value, &res)) {
+ OUT_OF_SPACE_IF_NULL(res);
}
else {
if(!sym_set_type(value, &PyBool_Type)) {
goto hit_bottom;
}
+ res = value;
}
+ stack_pointer[-1] = res;
break;
}
@@ -132,18 +139,15 @@
_Py_UopsSymbol *value;
_Py_UopsSymbol *res;
value = stack_pointer[-1];
- if (sym_is_const(value) && sym_matches_type(value, &PyLong_Type)) {
- PyObject *load = _PyLong_IsZero((PyLongObject *)sym_get_const(value))
- ? Py_False : Py_True;
- REPLACE_OP(this_instr, _POP_TOP_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)load);
- OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, load));
+ if (optimize_to_bool(this_instr, ctx, value, &res)) {
+ OUT_OF_SPACE_IF_NULL(res);
}
else {
+ if(!sym_set_type(value, &PyLong_Type)) {
+ goto hit_bottom;
+ }
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
}
- if(!sym_set_type(value, &PyLong_Type)) {
- goto hit_bottom;
- }
stack_pointer[-1] = res;
break;
}
@@ -152,10 +156,15 @@
_Py_UopsSymbol *value;
_Py_UopsSymbol *res;
value = stack_pointer[-1];
- if(!sym_set_type(value, &PyList_Type)) {
- goto hit_bottom;
+ if (optimize_to_bool(this_instr, ctx, value, &res)) {
+ OUT_OF_SPACE_IF_NULL(res);
+ }
+ else {
+ if(!sym_set_type(value, &PyList_Type)) {
+ goto hit_bottom;
+ }
+ OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
}
- OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
stack_pointer[-1] = res;
break;
}
@@ -164,11 +173,15 @@
_Py_UopsSymbol *value;
_Py_UopsSymbol *res;
value = stack_pointer[-1];
- if (sym_get_const(value) == Py_None) {
- REPLACE_OP(this_instr, _POP_TOP_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)Py_False);
+ if (optimize_to_bool(this_instr, ctx, value, &res)) {
+ OUT_OF_SPACE_IF_NULL(res);
+ }
+ else {
+ if (!sym_set_const(value, Py_None)) {
+ goto hit_bottom;
+ }
+ OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, Py_False));
}
- sym_set_const(value, Py_None);
- OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, Py_False));
stack_pointer[-1] = res;
break;
}
@@ -177,16 +190,14 @@
_Py_UopsSymbol *value;
_Py_UopsSymbol *res;
value = stack_pointer[-1];
- if (sym_is_const(value) && sym_matches_type(value, &PyUnicode_Type)) {
- PyObject *load = sym_get_const(value) == &_Py_STR(empty) ? Py_False : Py_True;
- REPLACE_OP(this_instr, _POP_TOP_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)load);
- OUT_OF_SPACE_IF_NULL(res = sym_new_const(ctx, load));
+ if (optimize_to_bool(this_instr, ctx, value, &res)) {
+ OUT_OF_SPACE_IF_NULL(res);
}
else {
OUT_OF_SPACE_IF_NULL(res = sym_new_type(ctx, &PyBool_Type));
- }
- if(!sym_set_type(value, &PyUnicode_Type)) {
- goto hit_bottom;
+ if(!sym_set_type(value, &PyUnicode_Type)) {
+ goto hit_bottom;
+ }
}
stack_pointer[-1] = res;
break;