-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-100239: Propagate type info through _BINARY_OP_EXTEND in tier 2 #148146
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Propagate result type and uniqueness information through | ||
| ``_BINARY_OP_EXTEND`` in the tier 2 optimizer, enabling elimination of | ||
| downstream type guards and selection of inplace float operations. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2195,24 +2195,24 @@ LONG_FLOAT_ACTION(compactlong_float_true_div, /) | |
|
|
||
| static _PyBinaryOpSpecializationDescr binaryop_extend_descrs[] = { | ||
| /* long-long arithmetic */ | ||
| {NB_OR, compactlongs_guard, compactlongs_or}, | ||
| {NB_AND, compactlongs_guard, compactlongs_and}, | ||
| {NB_XOR, compactlongs_guard, compactlongs_xor}, | ||
| {NB_INPLACE_OR, compactlongs_guard, compactlongs_or}, | ||
| {NB_INPLACE_AND, compactlongs_guard, compactlongs_and}, | ||
| {NB_INPLACE_XOR, compactlongs_guard, compactlongs_xor}, | ||
| {NB_OR, compactlongs_guard, compactlongs_or, &PyLong_Type, 1}, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These can return small int too right? In that case, the result would not be unique
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The contract is that operations making use of the uniqueness can handle small ints. (The inplace versions of BINARY_ADD_INT handle this for example). |
||
| {NB_AND, compactlongs_guard, compactlongs_and, &PyLong_Type, 1}, | ||
| {NB_XOR, compactlongs_guard, compactlongs_xor, &PyLong_Type, 1}, | ||
| {NB_INPLACE_OR, compactlongs_guard, compactlongs_or, &PyLong_Type, 1}, | ||
| {NB_INPLACE_AND, compactlongs_guard, compactlongs_and, &PyLong_Type, 1}, | ||
| {NB_INPLACE_XOR, compactlongs_guard, compactlongs_xor, &PyLong_Type, 1}, | ||
|
|
||
| /* float-long arithemetic */ | ||
| {NB_ADD, float_compactlong_guard, float_compactlong_add}, | ||
| {NB_SUBTRACT, float_compactlong_guard, float_compactlong_subtract}, | ||
| {NB_TRUE_DIVIDE, nonzero_float_compactlong_guard, float_compactlong_true_div}, | ||
| {NB_MULTIPLY, float_compactlong_guard, float_compactlong_multiply}, | ||
| {NB_ADD, float_compactlong_guard, float_compactlong_add, &PyFloat_Type, 1}, | ||
| {NB_SUBTRACT, float_compactlong_guard, float_compactlong_subtract, &PyFloat_Type, 1}, | ||
| {NB_TRUE_DIVIDE, nonzero_float_compactlong_guard, float_compactlong_true_div, &PyFloat_Type, 1}, | ||
| {NB_MULTIPLY, float_compactlong_guard, float_compactlong_multiply, &PyFloat_Type, 1}, | ||
|
|
||
| /* float-float arithmetic */ | ||
| {NB_ADD, compactlong_float_guard, compactlong_float_add}, | ||
| {NB_SUBTRACT, compactlong_float_guard, compactlong_float_subtract}, | ||
| {NB_TRUE_DIVIDE, nonzero_compactlong_float_guard, compactlong_float_true_div}, | ||
| {NB_MULTIPLY, compactlong_float_guard, compactlong_float_multiply}, | ||
| {NB_ADD, compactlong_float_guard, compactlong_float_add, &PyFloat_Type, 1}, | ||
| {NB_SUBTRACT, compactlong_float_guard, compactlong_float_subtract, &PyFloat_Type, 1}, | ||
| {NB_TRUE_DIVIDE, nonzero_compactlong_float_guard, compactlong_float_true_div, &PyFloat_Type, 1}, | ||
| {NB_MULTIPLY, compactlong_float_guard, compactlong_float_multiply, &PyFloat_Type, 1}, | ||
| }; | ||
|
|
||
| static int | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this always true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, here it is. In the pr this was factored out from we had more specializations where this would not always be true.
We can remove it here and add back later. I think it would be needed of we use the binary_op_extend as s mechanism for adding more cases to tier 2 without creating more tier 1 opcodes