Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

GH-115816: Make tier2 optimizer symbols testable, and add a few tests. #115953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 27, 2024
Prev Previous commit
Next Next commit
Swap top and bottom to better match standard type theory.
  • Loading branch information
markshannon committed Feb 22, 2024
commit 7e054bc7eb1f45bc79718a2b16ae2f3718f0eb58
32 changes: 16 additions & 16 deletions 32 Python/optimizer_symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ do { \

/*
static _Py_UOpsSymType *
make_top(_Py_UOpsAbstractInterpContext *ctx)
make_bottom(_Py_UOpsAbstractInterpContext *ctx)
markshannon marked this conversation as resolved.
Show resolved Hide resolved
{
_Py_UOpsSymType *top = _Py_uop_sym_new_unknown(ctx);
_Py_uop_sym_set_null(top);
_Py_uop_sym_set_type(top, &PyLong_Type);
return top;
_Py_UOpsSymType *sym = _Py_uop_sym_new_unknown(ctx);
_Py_uop_sym_set_null(sym);
_Py_uop_sym_set_type(sym, &PyLong_Type);
return sym;
}*/

PyObject *
Expand All @@ -303,26 +303,26 @@ _Py_uop_symbols_test(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(ignored))
_Py_UOpsAbstractInterpContext *ctx = &context;
_Py_uop_abstractcontext_init(ctx);

_Py_UOpsSymType *bottom = _Py_uop_sym_new_unknown(ctx);
if (bottom == NULL) {
_Py_UOpsSymType *top = _Py_uop_sym_new_unknown(ctx);
markshannon marked this conversation as resolved.
Show resolved Hide resolved
if (top == NULL) {
return NULL;
}
TEST_PREDICATE(!_Py_uop_sym_is_null(bottom), "unknown is NULL");
TEST_PREDICATE(!_Py_uop_sym_is_not_null(bottom), "unknown is not NULL");
TEST_PREDICATE(!_Py_uop_sym_is_const(bottom), "unknown is a constant");
// TEST_PREDICATE(_Py_uop_sym_get_const(bottom) == NULL, "unknown as constant is not NULL");
TEST_PREDICATE(!_Py_uop_sym_is_null(top), "unknown is NULL");
TEST_PREDICATE(!_Py_uop_sym_is_not_null(top), "unknown is not NULL");
TEST_PREDICATE(!_Py_uop_sym_is_const(top), "unknown is a constant");
// TEST_PREDICATE(_Py_uop_sym_get_const(top) == NULL, "unknown as constant is not NULL");

// _Py_UOpsSymType *top = make_top(ctx);
// TEST_PREDICATE(_Py_uop_sym_is_null(top), "top is NULL is not true");
// TEST_PREDICATE(_Py_uop_sym_is_not_null(top), "top is not NULL is not true");
// TEST_PREDICATE(_Py_uop_sym_is_const(top), "top is a constant is not true");
// _Py_UOpsSymType *bottom = make_bottom(ctx);
markshannon marked this conversation as resolved.
Show resolved Hide resolved
// TEST_PREDICATE(_Py_uop_sym_is_null(bottom), "bottom is NULL is not true");
// TEST_PREDICATE(_Py_uop_sym_is_not_null(bottom), "bottom is not NULL is not true");
// TEST_PREDICATE(_Py_uop_sym_is_const(bottom), "bottom is a constant is not true");

_Py_UOpsSymType *int_type = _Py_uop_sym_new_type(ctx, &PyLong_Type);
TEST_PREDICATE(_Py_uop_sym_matches_type(int_type, &PyLong_Type), "inconsistent type");
_Py_uop_sym_set_type(int_type, &PyLong_Type);
TEST_PREDICATE(_Py_uop_sym_matches_type(int_type, &PyLong_Type), "inconsistent type");
_Py_uop_sym_set_type(int_type, &PyFloat_Type);
// TEST_PREDICATE(_Py_uop_sym_matches_type(int_type, &PyLong_Type), "top doesn't match int");
// TEST_PREDICATE(_Py_uop_sym_matches_type(int_type, &PyLong_Type), "bottom doesn't match int");

_Py_uop_abstractcontext_fini(ctx);
Py_RETURN_NONE;
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.