[cmucl-commit] [git] CMU Common Lisp branch master updated. snapshot-2012-08-5-g5293d44

Raymond Toy rtoy at common-lisp.net
Sun Aug 19 14:58:15 UTC 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".

The branch, master has been updated
       via  5293d44e876c4d08a1a1f19b037a8afd54961eb8 (commit)
      from  441a76a6b156e8eedc5ef9bb72c5772d89b657bc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5293d44e876c4d08a1a1f19b037a8afd54961eb8
Author: Raymond Toy <toy.raymond at gmail.com>
Date:   Sun Aug 19 07:58:06 2012 -0700

    Floating-point micro-optimizations
    
    o Convert x/n to x*(1/n) when n is a power of two since 1/n has an
      exact representation.
    o Convert 2*x to x+x.

diff --git a/src/compiler/float-tran.lisp b/src/compiler/float-tran.lisp
index 7a82135..d0a3703 100644
--- a/src/compiler/float-tran.lisp
+++ b/src/compiler/float-tran.lisp
@@ -634,6 +634,28 @@
   (frob >)
   (frob =))
 
+;; Convert (/ x n) to (* x (/ n)) when x is a float and n is a power
+;; of two, because (/ n) can be reprsented exactly.
+(deftransform / ((x y) (float float) * :when :both)
+  (unless (constant-continuation-p y)
+    (give-up))
+  (let ((val (continuation-value y)))
+    (multiple-value-bind (frac exp sign)
+	(decode-float val)
+      (unless (= frac 0.5)
+	(give-up))
+      `(* x (float (/ ,val) x)))))
+
+;; Convert 2*x to x+x.
+(deftransform * ((x y) (float real) * :when :both)
+  (unless (constant-continuation-p y)
+    (give-up))
+  (let ((val (continuation-value y)))
+    (unless (= val 2)
+      (give-up))
+    '(+ x x)))
+
+	      
 
 ;;;; Irrational transforms:
 

-----------------------------------------------------------------------

Summary of changes:
 src/compiler/float-tran.lisp |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
CMU Common Lisp


More information about the cmucl-commit mailing list