Skip to content

Commit b3d8e3e

Browse files
committed
Add basic test
1 parent 8b9d977 commit b3d8e3e

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lib/test/test_capi/test_opt.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,25 @@ def testfunc(n):
28802880
self.assertIn("_POP_TOP_NOP", uops)
28812881
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
28822882

2883+
def test_binary_op_extend_float_long_add_refcount_elimination(self):
2884+
def testfunc(n):
2885+
a = 1.5
2886+
b = 2
2887+
res = 0.0
2888+
for _ in range(n):
2889+
res = a + b
2890+
return res
2891+
2892+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
2893+
self.assertEqual(res, 3.5)
2894+
self.assertIsNotNone(ex)
2895+
uops = get_opnames(ex)
2896+
for uop in uops:
2897+
print(uop)
2898+
self.assertIn("_BINARY_OP_EXTEND", uops)
2899+
self.assertIn("_POP_TOP_NOP", uops)
2900+
self.assertLessEqual(count_ops(ex, "_POP_TOP"), 2)
2901+
28832902
def test_remove_guard_for_slice_list(self):
28842903
def f(n):
28852904
for i in range(n):

0 commit comments

Comments
 (0)