From a376a47c6ceacf97759c94b5400b1e480c6c9203 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Tue, 30 Mar 2010 10:09:04 +0000 Subject: [PATCH] 1.0.37.17: multiplication-by-one misoptimization in (FLOAT-ACCURACY 0) policies * Our transforms optimized (* 1.0) into . Oops. --- NEWS | 2 ++ src/compiler/float-tran.lisp | 4 ++-- tests/compiler.pure.lisp | 18 ++++++++++++++++++ version.lisp-expr | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index ebd870cd6..e8f657fd7 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ changes relative to sbcl-1.0.36: * bug fix: a semaphore with multiple waiters and some of them unwinding due to timeouts could be left in an inconsistent state. * bug fix: fix typo in "Reporting Bugs" section of the manual (lp#520366) + * bug fix: misoptimization of multiplication by one in + (SB-C::FLOAT-ACCURACY 0) policies. changes in sbcl-1.0.37 relative to sbcl-1.0.36: * enhancement: Backtrace from THROW to uncaught tag on x86oids now shows diff --git a/src/compiler/float-tran.lisp b/src/compiler/float-tran.lisp index c9879b977..648f2f525 100644 --- a/src/compiler/float-tran.lisp +++ b/src/compiler/float-tran.lisp @@ -343,8 +343,8 @@ (if (minusp y) '(%negate x) 'x))))) - (def * single-float 1.0 -1.0) - (def * double-float 1.0d0 -1.0d0)) + (def single-float 1.0 -1.0) + (def double-float 1.0d0 -1.0d0)) ;;; Return the reciprocal of X if it can be represented exactly, NIL otherwise. (defun maybe-exact-reciprocal (x) diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index b261b83af..5ef755f79 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -3484,3 +3484,21 @@ (assert (not (ctu:find-named-callees fun))) (assert (= 1 (funcall fun #*000001))) (assert (= 0 (funcall fun #*000010))))) + +(with-test (:name :mult-by-one-in-float-acc-zero) + (assert (eql 1.0 (funcall (compile nil `(lambda (x) + (declare (optimize (sb-c::float-accuracy 0))) + (* x 1.0))) + 1))) + (assert (eql -1.0 (funcall (compile nil `(lambda (x) + (declare (optimize (sb-c::float-accuracy 0))) + (* x -1.0))) + 1))) + (assert (eql 1.0d0 (funcall (compile nil `(lambda (x) + (declare (optimize (sb-c::float-accuracy 0))) + (* x 1.0d0))) + 1))) + (assert (eql -1.0d0 (funcall (compile nil `(lambda (x) + (declare (optimize (sb-c::float-accuracy 0))) + (* x -1.0d0))) + 1)))) diff --git a/version.lisp-expr b/version.lisp-expr index a34cbb9e7..95f6627d4 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.37.16" +"1.0.37.17" -- 2.11.4.GIT