FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-115687: Split up guards from COMPARE_OP by Fidget-Spinner · Pull Request #115688 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .h  (6) .py  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 6 additions & 6 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

194 changes: 97 additions & 97 deletions Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 56 additions & 3 deletions Lib/test/test_capi/test_opt.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def _run_with_optimizer(self, testfunc, arg):
def test_int_type_propagation(self):
def testfunc(loops):
num = 0
while num < loops:
for i in range(loops):
x = num + num
a = x + 1
num += 1
Expand All @@ -593,7 +593,7 @@ def double(x):
return x + x
def testfunc(loops):
num = 0
while num < loops:
for i in range(loops):
x = num + num
a = double(x)
num += 1
Expand All @@ -617,7 +617,7 @@ def double(x):
return x + x
def testfunc(loops):
num = 0
while num < loops:
for i in range(loops):
a = double(num)
x = a + a
num += 1
Expand Down Expand Up @@ -821,6 +821,59 @@ def testfunc(n):
# We'll also need to verify that propagation actually occurs.
self.assertIn("_BINARY_OP_MULTIPLY_FLOAT", uops)

def test_compare_op_type_propagation_float(self):
def testfunc(n):
a = 1.0
for _ in range(n):
x = a == a
x = a == a
x = a == a
x = a == a
return x

res, ex = self._run_with_optimizer(testfunc, 32)
self.assertTrue(res)
self.assertIsNotNone(ex)
uops = {opname for opname, _, _ in ex}
guard_both_float_count = [opname for opname, _, _ in ex if opname == "_GUARD_BOTH_FLOAT"]
self.assertLessEqual(len(guard_both_float_count), 1)
self.assertIn("_COMPARE_OP_FLOAT", uops)

def test_compare_op_type_propagation_int(self):
def testfunc(n):
a = 1
for _ in range(n):
x = a == a
x = a == a
x = a == a
x = a == a
return x

res, ex = self._run_with_optimizer(testfunc, 32)
self.assertTrue(res)
self.assertIsNotNone(ex)
uops = {opname for opname, _, _ in ex}
guard_both_float_count = [opname for opname, _, _ in ex if opname == "_GUARD_BOTH_INT"]
self.assertLessEqual(len(guard_both_float_count), 1)
self.assertIn("_COMPARE_OP_INT", uops)

def test_compare_op_type_propagation_unicode(self):
def testfunc(n):
a = ""
for _ in range(n):
x = a == a
x = a == a
x = a == a
x = a == a
return x

res, ex = self._run_with_optimizer(testfunc, 32)
self.assertTrue(res)
self.assertIsNotNone(ex)
uops = {opname for opname, _, _ in ex}
guard_both_float_count = [opname for opname, _, _ in ex if opname == "_GUARD_BOTH_UNICODE"]
self.assertLessEqual(len(guard_both_float_count), 1)
self.assertIn("_COMPARE_OP_STR", uops)

if __name__ == "__main__":
unittest.main()
Loading

Back | FazBrowse Home | New Git URL