Commit c42a7a8
committed
gh-100239: Propagate type info through _BINARY_OP_EXTEND in tier 2
Adds two new fields to _PyBinaryOpSpecializationDescr:
- result_type: the static type of the result (or NULL if unknown).
- result_unique: nonzero iff `action` always returns a freshly
allocated object (not aliased to either operand).
The tier 2 optimizer now narrows the result symbol's type via
sym_new_type(d->result_type) and wraps it in PyJitRef_MakeUnique when
d->result_unique is set. This lets downstream ops elide their
operand-type guards and pick inplace variants. For example,
(2 + x) * y with x, y floats now compiles to
_BINARY_OP_MULTIPLY_FLOAT_INPLACE with _GUARD_NOS_FLOAT eliminated.
All existing descriptors populate both fields: long-long bitwise ops
produce unique PyLong results, and float/long mixed arithmetic
produces unique PyFloat results.
A test verifies the inplace-multiply case end-to-end.1 parent bce96a1 commit c42a7a8
File tree
6 files changed
+67
-18
lines changed- Include/internal
- Lib/test/test_capi
- Misc/NEWS.d/next/Core_and_Builtins
- Python
6 files changed
+67
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
499 | 506 | | |
500 | 507 | | |
501 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3813 | 3813 | | |
3814 | 3814 | | |
3815 | 3815 | | |
| 3816 | + | |
| 3817 | + | |
| 3818 | + | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
| 3822 | + | |
| 3823 | + | |
| 3824 | + | |
| 3825 | + | |
| 3826 | + | |
| 3827 | + | |
| 3828 | + | |
| 3829 | + | |
| 3830 | + | |
| 3831 | + | |
| 3832 | + | |
| 3833 | + | |
| 3834 | + | |
| 3835 | + | |
| 3836 | + | |
| 3837 | + | |
| 3838 | + | |
3816 | 3839 | | |
3817 | 3840 | | |
3818 | 3841 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
414 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
415 | 423 | | |
416 | 424 | | |
417 | 425 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2195 | 2195 | | |
2196 | 2196 | | |
2197 | 2197 | | |
2198 | | - | |
2199 | | - | |
2200 | | - | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
2204 | 2204 | | |
2205 | 2205 | | |
2206 | | - | |
2207 | | - | |
2208 | | - | |
2209 | | - | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
2210 | 2210 | | |
2211 | 2211 | | |
2212 | | - | |
2213 | | - | |
2214 | | - | |
2215 | | - | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
2216 | 2216 | | |
2217 | 2217 | | |
2218 | 2218 | | |
| |||
0 commit comments