Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
GH-132732: Use pure op machinery to optimize various instructions with _POP_TOP and _POP_TWO#137577
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b4b2106cc4b9ce2d5f4288e7023de75ca803b37082e7a1e7ef69228a01a8e2a443a92449bd7c92ada46b024690c7945c1955d098f4c614a0fc293dcef5b7c89cee967b160d20c6edbf9File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Optimize ``_COMPARE_OP``, ``_CONTAINS_OP``, ``_UNARY_NEGATIVE``, ``_UNARY_NOT``, and ``_UNARY_INVERT`` in JIT builds with constant-loading uops (``_POP_TWO_LOAD_CONST_INLINE_BORROW`` and ``_POP_TOP_LOAD_CONST_INLINE_BORROW``), and then remove both to reduce instruction count. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -397,6 +397,7 @@ dummy_func(void) { | ||
| } | ||
| op(_UNARY_NEGATIVE, (value -- res)) { | ||
| REPLACE_OPCODE_IF_EVALUATES_PURE(value); | ||
| if (sym_is_compact_int(value)) { | ||
| res = sym_new_compact_int(ctx); | ||
| } | ||
| @@ -412,6 +413,10 @@ dummy_func(void) { | ||
| } | ||
| op(_UNARY_INVERT, (value -- res)) { | ||
| // Required to avoid a warning due to the deprecation of bitwise inversion of bools | ||
| if (!sym_matches_type(value, &PyBool_Type)) { | ||
| REPLACE_OPCODE_IF_EVALUATES_PURE(value); | ||
| } | ||
| if (sym_matches_type(value, &PyLong_Type)) { | ||
| res = sym_new_type(ctx, &PyLong_Type); | ||
| } | ||
| @@ -421,6 +426,9 @@ dummy_func(void) { | ||
| } | ||
| op(_COMPARE_OP, (left, right -- res)) { | ||
| // Comparison between bytes and str or int is not impacted by this optimization as bytes | ||
| // is not a safe type (due to its ability to raise a warning during comparisons). | ||
| REPLACE_OPCODE_IF_EVALUATES_PURE(left, right); | ||
savannahostrowski marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if (oparg & 16) { | ||
| res = sym_new_type(ctx, &PyBool_Type); | ||
| } | ||
| @@ -449,6 +457,7 @@ dummy_func(void) { | ||
| } | ||
| op(_CONTAINS_OP, (left, right -- b)) { | ||
| REPLACE_OPCODE_IF_EVALUATES_PURE(left, right); | ||
| b = sym_new_type(ctx, &PyBool_Type); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.