-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-115480: Type propagate _BINARY_OP_ADD_UNICODE #115710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -775,10 +775,13 @@ def testfunc(n): | |
a = 1.0 | ||
for _ in range(n): | ||
a = a + 0.1 | ||
a = a + 0.1 | ||
a = a + 0.1 | ||
a = a + 0.1 | ||
return a | ||
|
||
res, ex = self._run_with_optimizer(testfunc, 32) | ||
self.assertAlmostEqual(res, 4.2) | ||
self.assertAlmostEqual(res, 13.8) | ||
self.assertIsNotNone(ex) | ||
uops = {opname for opname, _, _ in ex} | ||
guard_both_float_count = [opname for opname, _, _ in ex if opname == "_GUARD_BOTH_FLOAT"] | ||
|
@@ -792,10 +795,13 @@ def testfunc(n): | |
a = 1.0 | ||
for _ in range(n): | ||
a = a - 0.1 | ||
a = a - 0.1 | ||
a = a - 0.1 | ||
a = a - 0.1 | ||
return a | ||
|
||
res, ex = self._run_with_optimizer(testfunc, 32) | ||
self.assertAlmostEqual(res, -2.2) | ||
self.assertAlmostEqual(res, -11.8) | ||
self.assertIsNotNone(ex) | ||
uops = {opname for opname, _, _ in ex} | ||
guard_both_float_count = [opname for opname, _, _ in ex if opname == "_GUARD_BOTH_FLOAT"] | ||
|
@@ -809,10 +815,13 @@ def testfunc(n): | |
a = 1.0 | ||
for _ in range(n): | ||
a = a * 2.0 | ||
a = a * 2.0 | ||
a = a * 2.0 | ||
a = a * 2.0 | ||
return a | ||
|
||
res, ex = self._run_with_optimizer(testfunc, 32) | ||
self.assertAlmostEqual(res, 2 ** 32) | ||
self.assertAlmostEqual(res, 2 ** (32 * 4)) | ||
self.assertIsNotNone(ex) | ||
uops = {opname for opname, _, _ in ex} | ||
guard_both_float_count = [opname for opname, _, _ in ex if opname == "_GUARD_BOTH_FLOAT"] | ||
|
@@ -821,6 +830,24 @@ def testfunc(n): | |
# We'll also need to verify that propagation actually occurs. | ||
self.assertIn("_BINARY_OP_MULTIPLY_FLOAT", uops) | ||
|
||
def test_add_unicode_propagation(self): | ||
def testfunc(n): | ||
a = "" | ||
for _ in range(n): | ||
a + a | ||
a + a | ||
a + a | ||
a + a | ||
Comment on lines
+858
to
+861
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sooner or later we'll have a peephole pass that will delete the generated code for this completely. Is there a reason you're not doing something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That transforms it to |
||
return a | ||
|
||
res, ex = self._run_with_optimizer(testfunc, 32) | ||
self.assertEqual(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("_BINARY_OP_ADD_UNICODE", uops) | ||
|
||
def test_compare_op_type_propagation_float(self): | ||
def testfunc(n): | ||
a = 1.0 | ||
|
Uh oh!
There was an error while loading. Please reload this page.