Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r73742:03e137fd14b3 Date: 2014-09-28 22:45 +0200 http://bitbucket.org/pypy/pypy/changeset/03e137fd14b3/
Log: Test and fix (for 64-bit only): the nonnull() method of ConstFloat and BoxFloat was implemented with "self.value != 0.0", which returns false for both 0.0 and -0.0. But the real intent of this method is to check if the value is null in the sense that a pattern of zeros is a correct initialization for the value. diff --git a/rpython/jit/metainterp/history.py b/rpython/jit/metainterp/history.py --- a/rpython/jit/metainterp/history.py +++ b/rpython/jit/metainterp/history.py @@ -285,7 +285,7 @@ return False def nonnull(self): - return self.value != longlong.ZEROF + return bool(longlong.extract_bits(self.value)) def _getrepr_(self): return self.getfloat() @@ -460,7 +460,7 @@ return longlong.gethash(self.value) def nonnull(self): - return self.value != longlong.ZEROF + return bool(longlong.extract_bits(self.value)) def _getrepr_(self): return self.getfloat() diff --git a/rpython/jit/metainterp/test/test_history.py b/rpython/jit/metainterp/test/test_history.py --- a/rpython/jit/metainterp/test/test_history.py +++ b/rpython/jit/metainterp/test/test_history.py @@ -59,6 +59,20 @@ assert not c5.same_constant(c2) assert not c5.same_constant(c4) +def test_float_nonnull(): + c1 = Const._new(0.0) + c2 = Const._new(1.0) + c3 = Const._new(INFINITY) + c4 = Const._new(-INFINITY) + c5 = Const._new(NAN) + c6 = Const._new(-0.0) + assert not c1.nonnull() + assert c2.nonnull() + assert c3.nonnull() + assert c4.nonnull() + assert c5.nonnull() + assert c6.nonnull() + class TestZTranslated(StandaloneTests): def test_ztranslated_same_constant_float(self): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit