Skip to content

Commit 697323b

Browse files
add test for optimization
1 parent 1a47c8d commit 697323b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@ def testfunc(n):
14181418
self.assertNotIn("_GUARD_NOS_INT", uops)
14191419
self.assertNotIn("_GUARD_TOS_INT", uops)
14201420

1421+
14211422
def test_decref_escapes(self):
14221423
class Convert9999ToNone:
14231424
def __del__(self):
@@ -1564,6 +1565,23 @@ def f(n):
15641565
# But all of the appends we care about are still there:
15651566
self.assertEqual(uops.count("_CALL_LIST_APPEND"), len("ABCDEFG"))
15661567

1568+
def test_compare_pop_two_load_const_inline_borrow(self):
1569+
def testfunc(n):
1570+
x = 0
1571+
for _ in range(n):
1572+
a = 10
1573+
b = 10
1574+
if a == b:
1575+
x += 1
1576+
return x
1577+
1578+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1579+
self.assertEqual(res, 1)
1580+
self.assertIsNotNone(ex)
1581+
uops = get_opnames(ex)
1582+
self.assertNotIn("_COMPARE_OP_INT", uops)
1583+
self.assertNotIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
1584+
15671585
def global_identity(x):
15681586
return x
15691587

0 commit comments

Comments
 (0)