Skip to content

Commit 8723267

Browse files
Works for int
1 parent 8341b8d commit 8723267

File tree

3 files changed

+24
-156
lines changed

3 files changed

+24
-156
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ def testfunc(n):
863863
uops = get_opnames(ex)
864864
self.assertNotIn("_GUARD_TOS_INT", uops)
865865
self.assertNotIn("_GUARD_NOS_INT", uops)
866-
self.assertIn("_BINARY_OP_ADD_INT", uops)
866+
self.assertNotIn("_BINARY_OP_ADD_INT", uops)
867+
self.assertNotIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
867868
# Try again, but between the runs, set the global to a float.
868869
# This should result in no executor the second time.
869870
ns = {}
@@ -1463,7 +1464,8 @@ def testfunc(n):
14631464
self.assertEqual(res, 3)
14641465
self.assertIsNotNone(ex)
14651466
uops = get_opnames(ex)
1466-
self.assertIn("_BINARY_OP_ADD_INT", uops)
1467+
self.assertNotIn("_BINARY_OP_ADD_INT", uops)
1468+
self.assertNotIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
14671469
self.assertNotIn("_GUARD_NOS_INT", uops)
14681470
self.assertNotIn("_GUARD_TOS_INT", uops)
14691471

@@ -1613,40 +1615,6 @@ def f(n):
16131615
# But all of the appends we care about are still there:
16141616
self.assertEqual(uops.count("_CALL_LIST_APPEND"), len("ABCDEFG"))
16151617

1616-
def test_compare_pop_two_load_const_inline_borrow_int(self):
1617-
def testfunc(n):
1618-
x = 0
1619-
for _ in range(n):
1620-
a = 10
1621-
b = 10
1622-
if a == b:
1623-
x += 1
1624-
return x
1625-
1626-
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1627-
self.assertEqual(res, TIER2_THRESHOLD)
1628-
self.assertIsNotNone(ex)
1629-
uops = get_opnames(ex)
1630-
self.assertNotIn("_COMPARE_OP_INT", uops)
1631-
self.assertNotIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
1632-
1633-
def test_compare_pop_two_load_const_inline_borrow_float(self):
1634-
def testfunc(n):
1635-
x = 0
1636-
for _ in range(n):
1637-
a = 10.0
1638-
b = 10.0
1639-
if a == b:
1640-
x += 1
1641-
return x
1642-
1643-
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
1644-
self.assertEqual(res, TIER2_THRESHOLD)
1645-
self.assertIsNotNone(ex)
1646-
uops = get_opnames(ex)
1647-
self.assertNotIn("_COMPARE_OP_FLOAT", uops)
1648-
self.assertNotIn("_POP_TWO_LOAD_CONST_INLINE_BORROW", uops)
1649-
16501618
def test_to_bool_bool_contains_op_set(self):
16511619
"""
16521620
Test that _TO_BOOL_BOOL is removed from code like:

Python/optimizer_bytecodes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,12 @@ dummy_func(void) {
435435
}
436436

437437
op(_COMPARE_OP_FLOAT, (left, right -- res)) {
438-
REPLACE_OPCODE_IF_EVALUATES_PURE(left, right);
438+
// REPLACE_OPCODE_IF_EVALUATES_PURE(left, right);
439439
res = sym_new_type(ctx, &PyBool_Type);
440440
}
441441

442442
op(_COMPARE_OP_STR, (left, right -- res)) {
443-
REPLACE_OPCODE_IF_EVALUATES_PURE(left, right);
443+
// REPLACE_OPCODE_IF_EVALUATES_PURE(left, right);
444444
res = sym_new_type(ctx, &PyBool_Type);
445445
}
446446

Python/optimizer_cases.c.h

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

0 commit comments

Comments
 (0)