Skip to content

Commit 48317fe

Browse files
authored
gh-146640: Optimize int operations by mutating uniquely-referenced operands in place (JIT only) (GH-146641)
1 parent 80ab6d9 commit 48317fe

9 files changed

Lines changed: 2331 additions & 1262 deletions

File tree

‎Include/internal/pycore_uop_ids.h‎

Lines changed: 1280 additions & 1256 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_uop_metadata.h‎

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Lib/test/test_capi/test_opt.py‎

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,6 +3390,154 @@ def testfunc(args):
33903390
uops = get_opnames(ex)
33913391
self.assertNotIn("_UNARY_NEGATIVE_FLOAT_INPLACE", uops)
33923392

3393+
def test_int_add_inplace_unique_lhs(self):
3394+
# a * b produces a unique compact int; adding c reuses it in place
3395+
def testfunc(args):
3396+
a, b, c, n = args
3397+
total = 0
3398+
for _ in range(