Skip to content

Commit e7a1e7e

Browse files
UNARY_NEGATIVE
1 parent 3b37082 commit e7a1e7e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,23 @@ def f(n):
16141614
# But all of the appends we care about are still there:
16151615
self.assertEqual(uops.count("_CALL_LIST_APPEND"), len("ABCDEFG"))
16161616

1617+
def test_unary_negative_pop_top_load_const_inline_borrow(self):
1618+
def testfunc(n):
1619+
x = 0
1620+
for i in range(n):
1621+
a = 1 # This will make -1, which is definitely immortal
1622+
result = -a
1623+
if result < 0:
1624+
x += 1
1625+
return x
1626+
1627+
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1628+
self.assertEqual(res, TIER2_THRESHOLD)
1629+
self.assertIsNotNone(ex)
1630+
uops = get_opnames(ex)
1631+
self.assertNotIn("_UNARY_NEGATIVE", uops)
1632+
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
1633+
16171634
def test_unary_not_pop_top_load_const_inline_borrow(self):
16181635
def testfunc(n):
16191636
x = 0

0 commit comments

Comments
 (0)