Issue #11244: Remove outdated peepholer check that was preventing the peepholer from folding -0 and -0.0. Thanks Eugene Toder for the patch.

This commit is contained in:
Mark Dickinson 2011-03-23 17:59:37 +00:00
parent ba7b560c1d
commit 7c9e803284
4 changed files with 17 additions and 4 deletions

View file

@ -3,6 +3,7 @@ import re
import sys
from io import StringIO
import unittest
from math import copysign
def disassemble(func):
f = StringIO()
@ -207,6 +208,9 @@ class TestTranforms(unittest.TestCase):
def test_folding_of_unaryops_on_constants(self):
for line, elem in (
('-0.5', '(-0.5)'), # unary negative
('-0.0', '(-0.0)'), # -0.0
('-(1.0-1.0)','(-0.0)'), # -0.0 after folding
('-0', '(0)'), # -0
('~-2', '(1)'), # unary invert
('+1', '(1)'), # unary positive
):
@ -214,6 +218,13 @@ class TestTranforms(unittest.TestCase):
self.assertIn(elem, asm, asm)
self.assertNotIn('UNARY_', asm)
# Check that -0.0 works after marshaling
def negzero():
return -(1.0-1.0)
self.assertNotIn('UNARY_', disassemble(negzero))
self.assertTrue(copysign(1.0, negzero()) < 0)
# Verify that unfoldables are skipped
for line, elem in (
('-"abc"', "('abc')"), # unary negative