1.0.29.28: optimize (EXPT -1 INTEGER)
authorNikodemus Siivola <nikodemus@random-state.net>
Sun, 21 Jun 2009 18:19:25 +0000 (18:19 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Sun, 21 Jun 2009 18:19:25 +0000 (18:19 +0000)
* Patch by Stas Boukarev.

NEWS
src/compiler/float-tran.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index deb4eb7..f1845f7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,8 @@
     about object allocation.
   * optimization: more efficient type-checks for FIXNUMs when the value
     is known to be a signed word on x86 and x86-64.
+  * optimization: (EXPT -1 INTEGER) is compiled into (IF (EVENP INTEGER) 1 -1).
+    (thanks to Stas Boukarev)
   * improvement: failure to provide requested stack allocation compiler notes
     provided in all cases (requested stack allocation not happening without a
     note being issued is now considered a bug.)
index 681aa48..dc2cadc 100644 (file)
     'single-float))
 (deftransform expt ((x y) ((double-float 0d0) (signed-byte 32)) *)
   `(%pow x (coerce y 'double-float)))
+(deftransform expt ((x y) ((integer -1 -1) integer) *)
+  `(if (evenp y) 1 -1))
 
 ;;; ANSI says log with base zero returns zero.
 (deftransform log ((x y) (float float) float)
index 37d4dde..c27e3d6 100644 (file)
@@ -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.29.27"
+"1.0.29.28"